lib/extensions/mspec/mspec/runner/formatters/dotted.rb in rhodes-5.5.18 vs lib/extensions/mspec/mspec/runner/formatters/dotted.rb in rhodes-6.0.11
- old
+ new
@@ -1,16 +1,17 @@
require 'mspec/expectations/expectations'
require 'mspec/runner/actions/timer'
require 'mspec/runner/actions/tally'
+require 'mspec/runner/actions/leakchecker' if ENV['CHECK_LEAKS']
class DottedFormatter
attr_reader :exceptions, :timer, :tally
def initialize(out=nil)
@exception = @failure = false
@exceptions = []
- @count = 0
+ @count = 0 # For subclasses
if out.nil?
@out = $stdout
else
@out = File.open out, "w"
end
@@ -22,10 +23,11 @@
# registers them. Registers +self+ for the +:exception+,
# +:before+, +:after+, and +:finish+ actions.
def register
(@timer = TimerAction.new).register
(@tally = TallyAction.new).register
+ LeakCheckerAction.new.register if ENV['CHECK_LEAKS']
@counter = @tally.counter
MSpec.register :exception, self
MSpec.register :before, self
MSpec.register :after, self
@@ -33,11 +35,11 @@
MSpec.register :abort, self
end
def abort
if @current_state
- puts " aborting example: #{@current_state.description}"
+ puts "\naborting example: #{@current_state.description}"
end
end
# Returns true if any exception is raised while running
# an example. This flag is reset before each example
@@ -92,19 +94,24 @@
# evaluating the examples.
def finish
print "\n"
count = 0
@exceptions.each do |exc|
- outcome = exc.failure? ? "FAILED" : "ERROR"
- print "\n#{count += 1})\n#{exc.description} #{outcome}\n"
- print exc.message, "\n"
- print exc.backtrace, "\n"
+ count += 1
+ print_exception(exc, count)
end
print "\n#{@timer.format}\n\n#{@tally.format}\n"
end
+ def print_exception(exc, count)
+ outcome = exc.failure? ? "FAILED" : "ERROR"
+ print "\n#{count})\n#{exc.description} #{outcome}\n"
+ print exc.message, "\n"
+ print exc.backtrace, "\n"
+ end
+
# A convenience method to allow printing to different outputs.
def print(*args)
@out.print(*args)
- @out.flush rescue nil #IronRuby throws a .NET exception on IO.flush
+ @out.flush
end
end