lib/dox/formatter.rb in dox-1.0.2 vs lib/dox/formatter.rb in dox-1.1.0
- old
+ new
@@ -1,13 +1,14 @@
require 'rspec/core'
require 'rspec/core/formatters/base_formatter'
+require 'rspec/core/formatters/console_codes'
module Dox
class Formatter < RSpec::Core::Formatters::BaseFormatter
extend Forwardable
- RSpec::Core::Formatters.register self, :example_passed, :stop
+ RSpec::Core::Formatters.register self, :example_passed, :stop, :dump_summary
def initialize(output)
super
self.passed_examples = {}
end
@@ -15,11 +16,21 @@
def example_passed(passed)
self.current_example = CurrentExample.new(passed.example)
move_example_to_passed if current_example.document?
end
- def stop(_notification)
- printer.print(passed_examples)
+ def stop(notification)
+ if notification.failed_examples.any?
+ $stderr.puts(notification.fully_formatted_failed_examples)
+ else
+ printer.print(passed_examples)
+ end
+ end
+
+ def dump_summary(summary)
+ return if summary.failed_examples.none?
+ $stderr.puts(summary.fully_formatted)
+ exit(-1)
end
private
attr_accessor :passed_examples