Permalink
Browse files

Added ExampleGroup.run_all method for specs only

  • Loading branch information...
1 parent 8363707 commit 6c425ed32c81fccc72882f47526910663abae4db @dchelimsky dchelimsky committed Apr 23, 2010
Showing with 9 additions and 10 deletions.
  1. +3 −10 spec/rspec/core/example_spec.rb
  2. +6 −0 spec/spec_helper.rb
@@ -62,16 +62,13 @@
end
describe "#run" do
- let(:reporter) { double('reporter').as_null_object }
-
it "should run after(:each) when the example passes" do
after_run = false
group = Rspec::Core::ExampleGroup.create do
after(:each) { after_run = true }
example('example') { 1.should == 1 }
end
- group.stub(:examples_to_run) { group.examples }
- group.run(reporter)
+ group.run_all
after_run.should be_true, "expected after(:each) to be run"
end
@@ -81,8 +78,7 @@
after(:each) { after_run = true }
example('example') { 1.should == 2 }
end
- group.stub(:examples_to_run) { group.examples }
- group.run(reporter)
+ group.run_all
after_run.should be_true, "expected after(:each) to be run"
end
@@ -92,11 +88,8 @@
after(:each) { after_run = true }
example('example') { raise "this error" }
end
- group.stub(:examples_to_run) { group.examples }
- group.run(reporter)
+ group.run_all
after_run.should be_true, "expected after(:each) to be run"
end
-
end
-
end
View
@@ -36,6 +36,12 @@ def self.create(*args, &example_group_block)
describe(*args, &example_group_block || lambda {})
Rspec::Core.world.example_groups.pop
end
+
+ def self.run_all(reporter=nil)
+ reporter ||= Rspec::Mocks::Mock.new('reporter').as_null_object
+ examples_to_run.replace(examples)
+ run(reporter)
+ end
end
def use_formatter(new_formatter)

0 comments on commit 6c425ed

Please sign in to comment.