Permalink
Browse files

improve some abstractions (pairing w/ Corey Haines)

  • Loading branch information...
1 parent bb15f4f commit 8eaf97bd1fe228bb770c088fad962bb543c1ab90 @dchelimsky dchelimsky committed Apr 7, 2010
Showing with 18 additions and 6 deletions.
  1. +3 −1 lib/rspec/core/formatters/base_formatter.rb
  2. +15 −5 lib/rspec/core/runner.rb
@@ -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)
View
@@ -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
@@ -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

0 comments on commit 8eaf97b

Please sign in to comment.