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

60
61
62
# File 'lib/rspec/core/notifications.rb', line 60
def initialize(reporter)
  @reporter = reporter
end

Instance Method Details

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

Returns list of examples

Returns:

65
66
67
# File 'lib/rspec/core/notifications.rb', line 65
def examples
  @reporter.examples
end

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

Returns list of failed examples

Returns:

70
71
72
# File 'lib/rspec/core/notifications.rb', line 70
def failed_examples
  @reporter.failed_examples
end

- (Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed examples as notifications) failure_notifications

Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed examples as notifications

Returns:

  • (Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed examples as notifications)

    Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed examples as notifications

87
88
89
# File 'lib/rspec/core/notifications.rb', line 87
def failure_notifications
  @failed_notifications ||= format(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.

93
94
95
96
97
98
99
100
101
# File 'lib/rspec/core/notifications.rb', line 93
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.

105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rspec/core/notifications.rb', line 105
def fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
  formatted = "\nPending:\n"
  pending_examples.each do |example|
    formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
    formatted <<
      "  #{colorizer.wrap(example.full_description, :pending)}\n" <<
      "    # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" <<
      "    # #{colorizer.wrap(formatted_caller, :detail)}\n"
  end
  formatted
end

- (Array(Rspec::Core::Notifications::ExampleNotification] returns examples as notifications) notifications

Array(Rspec::Core::Notifications::ExampleNotification] returns examples as notifications

Returns:

  • (Array(Rspec::Core::Notifications::ExampleNotification] returns examples as notifications)

    Array(Rspec::Core::Notifications::ExampleNotification] returns examples as notifications

81
82
83
# File 'lib/rspec/core/notifications.rb', line 81
def notifications
  @notifications ||= format(examples)
end

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

Returns list of pending examples

Returns:

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