Created
July 25, 2011 22:12
-
-
Save dreamr/1105372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
.each requires an array. If the value is nil enumerators raise exceptions
…On Jul 26, 2011 2:17 PM, "toothrot" < ***@***.***> wrote:
this is cool, but I have a couple notes:
it should probably be optional
why do you use for/in rather than .each? just seems a bit uncommon in ruby
in general.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1105372
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is cool, but I have a couple notes:
it should probably be optional
why do you use for/in rather than .each? just seems a bit uncommon in ruby in general.