Parent

Class/Module Index [+]

Quicksearch

RSpec::Core::Notifications::FailedExampleNotification

The `FailedExampleNotification` extends `ExampleNotification` with things useful for failed specs.

@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 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 181
def colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
  formatted_backtrace.map do |backtrace_info|
    colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color
  end
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 164
def colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
  add_shared_group_line(failure_lines, colorizer).map do |line|
    colorizer.wrap line, RSpec.configuration.failure_color
  end
end
description() click to toggle source

@return [String] The example description

# File lib/rspec/core/notifications.rb, line 149
def description
  example.full_description
end
exception() click to toggle source

@return [Exception] The example failure

# File lib/rspec/core/notifications.rb, line 144
def exception
  example.execution_result.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 173
def formatted_backtrace
  backtrace_formatter.format_backtrace(exception.backtrace, example.metadata)
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 189
def fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
  formatted = "\n  #{failure_number}) #{description}\n"

  colorized_message_lines(colorizer).each do |line|
    formatted << "     #{line}\n"
  end

  colorized_formatted_backtrace(colorizer).each do |line|
    formatted << "     #{line}\n"
  end

  formatted
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 156
def message_lines
  add_shared_group_line(failure_lines, NullColorizer)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.