class RSpec::Core::Notifications::FailedExampleNotification

The ‘FailedExampleNotification` extends `ExampleNotification` with things useful for examples that have failure info – typically a failed or pending spec.

@example

def example_failed(notification)
  puts "Hey I failed :("
  puts "Here's my stack trace"
  puts notification.exception.backtrace.join("\n")
end

@attr [RSpec::Core::Example] example the current example @see ExampleNotification

Public Class Methods

new(example, exception_presenter=Formatters::ExceptionPresenter::Factory.new(example).build) click to toggle source
Calls superclass method
# File lib/rspec/core/notifications.rb, line 211
def initialize(example, exception_presenter=Formatters::ExceptionPresenter::Factory.new(example).build)
  @exception_presenter = exception_presenter
  super(example)
end

Public Instance Methods

colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes) click to toggle source

Returns the failures colorized formatted backtrace.

@param colorizer [#wrap] An object to colorize the message_lines by @return [Array<String>] the examples colorized backtrace lines

# File lib/rspec/core/notifications.rb, line 193
def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.colorized_formatted_backtrace(colorizer)
end
colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes) click to toggle source

Returns the message generated for this failure colorized line by line.

@param colorizer [#wrap] An object to colorize the message_lines by @return [Array<String>] The example failure message colorized

# File lib/rspec/core/notifications.rb, line 178
def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.colorized_message_lines(colorizer)
end
description() click to toggle source

@return [String] The example description

# File lib/rspec/core/notifications.rb, line 163
def description
  @exception_presenter.description
end
exception() click to toggle source

@return [Exception] The example failure

# File lib/rspec/core/notifications.rb, line 158
def exception
  @exception_presenter.exception
end
formatted_backtrace() click to toggle source

Returns the failures formatted backtrace.

@return [Array<String>] the examples backtrace lines

# File lib/rspec/core/notifications.rb, line 185
def formatted_backtrace
  @exception_presenter.formatted_backtrace
end
fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) click to toggle source

@return [String] The failure information fully formatted in the way that

RSpec's built-in formatters emit.
# File lib/rspec/core/notifications.rb, line 199
def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.fully_formatted(failure_number, colorizer)
end
fully_formatted_lines(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) click to toggle source

@return [Array<string>] The failure information fully formatted in the way that

RSpec's built-in formatters emit, split by line.
# File lib/rspec/core/notifications.rb, line 205
def fully_formatted_lines(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.fully_formatted_lines(failure_number, colorizer)
end
message_lines() click to toggle source

Returns the message generated for this failure line by line.

@return [Array<String>] The example failure message

# File lib/rspec/core/notifications.rb, line 170
def message_lines
  @exception_presenter.message_lines
end