123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::Notifications::ExampleNotification

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Struct
Instance Chain:
self, Struct
Inherits: Struct
  • Object
Defined in: rspec-core/lib/rspec/core/notifications.rb,
rspec-core/lib/rspec/core/notifications.rb

Overview

The ExampleNotification represents notifications sent by the reporter which contain information about the current (or soon to be) example. It is used by formatters to access information about that example.

Examples:

def example_started(notification)
  puts "Hey I started #{notification.example.description}"
end

Class Method Summary

Instance Attribute Summary

  • #example rw

    The ExampleNotification represents notifications sent by the reporter which contain information about the current (or soon to be) example.

Class Method Details

.for(example)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/notifications.rb', line 41

def self.for(example)
  execution_result = example.execution_result

  return SkippedExampleNotification.new(example) if execution_result.example_skipped?
  return new(example) unless execution_result.status == :pending || execution_result.status == :failed

  klass = if execution_result.pending_fixed?
            PendingExampleFixedNotification
          elsif execution_result.status == :pending
            PendingExampleFailedAsExpectedNotification
          else
            FailedExampleNotification
          end

  klass.new(example)
end

Instance Attribute Details

#example (rw)

The ExampleNotification represents notifications sent by the reporter which contain information about the current (or soon to be) example. It is used by formatters to access information about that example.

Examples:

def example_started(notification)
  puts "Hey I started #{notification.example.description}"
end
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/notifications.rb', line 38

ExampleNotification = Struct.new(:example)