Class: ErrorToCommunicate::RSpecFormatter
- Inherits:
-
RSpec::Core::Formatters::DocumentationFormatter
- Object
- RSpec::Core::Formatters::DocumentationFormatter
- ErrorToCommunicate::RSpecFormatter
- Defined in:
- lib/error_to_communicate/rspec_formatter.rb
Instance Method Summary collapse
-
#dump_failures(notification) ⇒ Object
Use ErrorToCommunicate to print error info rather than default DocumentationFormatter.
- #example_failed(failure_notification) ⇒ Object
-
#initialize ⇒ RSpecFormatter
constructor
A new instance of RSpecFormatter.
Constructor Details
#initialize ⇒ RSpecFormatter
Returns a new instance of RSpecFormatter.
86 87 88 89 |
# File 'lib/error_to_communicate/rspec_formatter.rb', line 86 def initialize(*) @num_failures = 0 super end |
Instance Method Details
#dump_failures(notification) ⇒ Object
Use ErrorToCommunicate to print error info rather than default DocumentationFormatter.
How did we figure out how to implement it? See “Down the rabbit hole” section in github.com/JoshCheek/what-we-ve-got-here-is-an-error-to-communicate/blob/ede6844/lib/error_to_communicate/rspec_formatter.rb#L68
FIXME: Needs to respect RSpec.configuration.color_enabled?
but we can't currently turn colour off in our output
111 112 113 114 115 116 117 118 |
# File 'lib/error_to_communicate/rspec_formatter.rb', line 111 def dump_failures(notification) output.puts "\nFailures:\n" notification.failure_notifications.each do |notification| heuristic = notification.example..fetch :heuristic formatted = Config.default.format heuristic, Dir.pwd output.puts formatted.chomp.gsub(/^/, ' ') end end |
#example_failed(failure_notification) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/error_to_communicate/rspec_formatter.rb', line 91 def example_failed(failure_notification) super # we must create it here, because it won't have access to the callstack later example = failure_notification.example example.[:heuristic] = Heuristic::RSpecFailure.new \ config: Config.default, # E2C heuristic, not RSpec's failure: failure_notification, failure_number: (@num_failures += 1), binding: Thread.current[:e2c_last_binding_seen] end |