Class: RSpec::Core::Notifications::ExamplesNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/notifications.rb

Overview

The ExamplesNotification represents notifications sent by the reporter which contain information about the suites examples.

Examples:

def stop(notification)
  puts "Hey I ran #{notification.examples.size}"
end

Instance Method Summary (collapse)

Constructor Details

- (ExamplesNotification) initialize(reporter)

Returns a new instance of ExamplesNotification

70
71
72
# File 'lib/rspec/core/notifications.rb', line 70
def initialize(reporter)
  @reporter = reporter
end

Instance Method Details

- (Array<RSpec::Core::Example>) examples

Returns list of examples

Returns:

75
76
77
# File 'lib/rspec/core/notifications.rb', line 75
def examples
  @reporter.examples
end

- (Array<RSpec::Core::Example>) failed_examples

Returns list of failed examples

Returns:

80
81
82
# File 'lib/rspec/core/notifications.rb', line 80
def failed_examples
  @reporter.failed_examples
end

- (Array<RSpec::Core::Notifications::FailedExampleNotification>) failure_notifications

Returns failed examples as notifications

Returns:

97
98
99
# File 'lib/rspec/core/notifications.rb', line 97
def failure_notifications
  @failed_notifications ||= format_examples(failed_examples)
end

- (String) fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)

Returns The list of failed examples, fully formatted in the way that RSpec's built-in formatters emit.

Returns:

  • (String)

    The list of failed examples, fully formatted in the way that RSpec's built-in formatters emit.

110
111
112
113
114
115
116
117
118
# File 'lib/rspec/core/notifications.rb', line 110
def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  formatted = "\nFailures:\n"
  failure_notifications.each_with_index do |failure, index|
    formatted += failure.fully_formatted(index.next, colorizer)
  end
  formatted
end

- (String) fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)

Returns The list of pending examples, fully formatted in the way that RSpec's built-in formatters emit.

Returns:

  • (String)

    The list of pending examples, fully formatted in the way that RSpec's built-in formatters emit.

122
123
124
125
126
127
128
129
130
# File 'lib/rspec/core/notifications.rb', line 122
def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup
  pending_notifications.each_with_index do |notification, index|
    formatted << notification.fully_formatted(index.next, colorizer)
  end
  formatted
end

- (Array<RSpec::Core::Notifications::ExampleNotification>) notifications

Returns examples as notifications

Returns:

91
92
93
# File 'lib/rspec/core/notifications.rb', line 91
def notifications
  @notifications ||= format_examples(examples)
end

- (Array<RSpec::Core::Example>) pending_examples

Returns list of pending examples

Returns:

85
86
87
# File 'lib/rspec/core/notifications.rb', line 85
def pending_examples
  @reporter.pending_examples
end

- (Array<RSpec::Core::Notifications::SkippedExampleNotification, RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification>) pending_notifications

returns pending examples as notifications

104
105
106
# File 'lib/rspec/core/notifications.rb', line 104
def pending_notifications
  @pending_notifications ||= format_examples(pending_examples)
end