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

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

#as_json

Instance Attribute Details

#exampleRSpec::Core::Example

the current example

Returns:



38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 38

def example
  @example
end

Class Method Details

.for(example) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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