Skip to content

Commit

Permalink
Added ExampleGroup.run_all method for specs only
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Apr 23, 2010
1 parent 8363707 commit 6c425ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 3 additions & 10 deletions spec/rspec/core/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6c425ed

Please sign in to comment.