Skip to content

Instantly share code, notes, and snippets.

@dreamr
Created July 25, 2011 22:12
Show Gist options
  • Save dreamr/1105372 to your computer and use it in GitHub Desktop.
Save dreamr/1105372 to your computer and use it in GitHub Desktop.
module Riot
Riot.reporter = Riot::VerboseStoryReporter
class Reporter
def initialize
@passes = @failures = @errors = 0
@failing_stories = @erroring_stories = []
@current_context = ""
end
def report(description, response)
code, result = *response
case code
when :pass then
@passes += 1
pass(description, result)
when :fail then
@failures += 1
message, line, file = *response[1..-1]
fail(description, message, line, file)
@failing_stories << [description, message, line, file]
when :error then
@errors += 1
error(description, result)
@erroring_stories << [description, result]
end
end
def final_report
for story in @failing_stories
fail(story[0], story[1], story[2], story[3])
end
for story in @erroring_stories
error(story[0], story[1])
end
end
end
def self.run
the_reporter = reporter.new(Riot.reporter_options)
the_reporter.summarize do
root_contexts.each { |ctx| ctx.run(the_reporter) }
end unless root_contexts.empty?
the_reporter.final_report
the_reporter
end
end
@dreamr
Copy link
Author

dreamr commented Jul 26, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment