Class: Ruber::RSpec::Version1Formatter

Inherits:
BaseFormatter show all
Defined in:
plugins/rspec/ruber_rspec_formatter.rb

Constant Summary

Constants inherited from BaseFormatter

ENDING_DELIMITER, STARTING_DELIMITER

Instance Method Summary (collapse)

Methods inherited from BaseFormatter

#dump_failure, #dump_failures, #dump_pending, #dump_summary, #example_passed, #example_started, #start, #write_data

Instance Method Details

- (nil) example_failed(ex, counter, failure)

Method called by RSpec after an example has been completed and failed

It writes to the output a YAML dump of a hash with the following entries:

  • :type: :failure
  • :description: the name of the failed example, made of the name of the example group and the description of the example itself
  • :exception: the name of the exception class which caused the failure
  • :message: the error message contained in the exception which caused the failure
  • :location: a string with the location (file name and line number) where the failure happened
  • :backtrace: a string containing the entries of the exception’s backtrace, joined by newlines

Parameters:

  • ex (Spec::Example::ExampleProxy)

    the failed example

  • counter (Integer)

    the number of the failed example

  • failure (Spec::Runner::Reporter::Failure)

    the object describing the failure

Returns:

  • (nil)


215
216
217
218
219
220
221
222
223
224
# File 'plugins/rspec/ruber_rspec_formatter.rb', line 215

def example_failed ex, counter, failure
  hash = {}
  hash[:type] = :failure
  hash[:description] = "#{@example_group.description} #{ex.description}"
  hash[:exception] = failure.exception.class.name
  hash[:message] = failure.exception.message
  hash[:location] = ex.location
  hash[:backtrace] = failure.exception.backtrace.join "\n"
  write_data hash
end

- (nil) example_pending(ex, msg)

Method called by RSpec after a pending example has been executed

It writes to the output a YAML dump of a hash with the following entries:

  • :type: :pending
  • :description: the name of the pending example, made of the name of the example group and the description of the example itself
  • :message: the message produced by pending
  • :location: a string with the location (file name and line number) of pending example

Parameters:

  • ex (Spec::Example::ExampleProxy)

    the pending example

  • msg (String)

    the message associated with the pending example

Returns:

  • (nil)


240
241
242
243
244
245
246
247
# File 'plugins/rspec/ruber_rspec_formatter.rb', line 240

def example_pending ex, msg
  hash = {}
  hash[:type] = :pending
  hash[:description] = "#{@example_group.description} #{ex.description}"
  hash[:message] = msg
  hash[:location] = ex.location
  write_data hash
end