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

#initialize(reporter) ⇒ ExamplesNotification

Returns a new instance of ExamplesNotification



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

def initialize(reporter)
  @reporter = reporter
end

Instance Method Details

#examplesArray<RSpec::Core::Example>

Returns list of examples

Returns:



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

def examples
  @reporter.examples
end

#failed_examplesArray<RSpec::Core::Example>

Returns list of failed examples

Returns:



77
78
79
# File 'lib/rspec/core/notifications.rb', line 77

def failed_examples
  @reporter.failed_examples
end

#failure_notificationsArray<RSpec::Core::Notifications::FailedExampleNotification>

Returns failed examples as notifications

Returns:



94
95
96
# File 'lib/rspec/core/notifications.rb', line 94

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

#fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ String

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.



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

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

#fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ String

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.



119
120
121
122
123
124
125
126
127
# File 'lib/rspec/core/notifications.rb', line 119

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"

  pending_notifications.each_with_index do |notification, index|
    formatted << notification.fully_formatted(index.next, colorizer)
  end

  formatted
end

#notificationsArray<RSpec::Core::Notifications::ExampleNotification>

Returns examples as notifications

Returns:



88
89
90
# File 'lib/rspec/core/notifications.rb', line 88

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

#pending_examplesArray<RSpec::Core::Example>

Returns list of pending examples

Returns:



82
83
84
# File 'lib/rspec/core/notifications.rb', line 82

def pending_examples
  @reporter.pending_examples
end

#pending_notificationsArray<RSpec::Core::Notifications::SkippedExampleNotification, RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification>

returns pending examples as notifications



101
102
103
# File 'lib/rspec/core/notifications.rb', line 101

def pending_notifications
  @pending_notifications ||= format_examples(pending_examples)
end