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)



58
59
60
# File 'lib/rspec/core/notifications.rb', line 58

def initialize(reporter)
  @reporter = reporter
end

Instance Method Details

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



63
64
65
# File 'lib/rspec/core/notifications.rb', line 63

def examples
  @reporter.examples
end

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



68
69
70
# File 'lib/rspec/core/notifications.rb', line 68

def failed_examples
  @reporter.failed_examples
end

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



85
86
87
# File 'lib/rspec/core/notifications.rb', line 85

def failure_notifications
  @failed_notifications ||= format_examples(failed_examples)
end

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



91
92
93
94
95
96
97
98
99
# File 'lib/rspec/core/notifications.rb', line 91

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)



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rspec/core/notifications.rb', line 103

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



79
80
81
# File 'lib/rspec/core/notifications.rb', line 79

def notifications
  @notifications ||= format_examples(examples)
end

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



73
74
75
# File 'lib/rspec/core/notifications.rb', line 73

def pending_examples
  @reporter.pending_examples
end