Skip to content

Commit

Permalink
improve some abstractions (pairing w/ Corey Haines)
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Apr 7, 2010
1 parent bb15f4f commit 8eaf97b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/rspec/core/formatters/base_formatter.rb
Expand Up @@ -28,8 +28,10 @@ def failed_examples
def report(count)
sync_output do
start(count)
# TODO - spec that we still dump even when there's
# an exception
begin
yield
yield self
ensure
stop
dump(@duration)
Expand Down
20 changes: 15 additions & 5 deletions lib/rspec/core/runner.rb
Expand Up @@ -24,11 +24,11 @@ def reporter
def run(args = [])
configure(args)

reporter.report(example_count) do
example_groups.inject(true) do |success, example_group|
success &= example_group.run(reporter)
end
reporter.report(example_count) do |reporter|
example_groups.run_all(reporter)
end

example_groups.success?
end

private
Expand All @@ -44,7 +44,17 @@ def example_count
end

def example_groups
Rspec::Core.world.example_groups_to_run
Rspec::Core.world.example_groups_to_run.extend(ExampleGroups)
end

module ExampleGroups
def run_all(reporter)
@success = self.inject(true) {|success, group| success &= group.run(reporter)}
end

def success?
@success ||= false
end
end

end
Expand Down

0 comments on commit 8eaf97b

Please sign in to comment.