Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #567 halt on toplevel before(:all) exceptions

  • Loading branch information...
commit 36702f441e1950e730b8ae3a22333f38c57c5568 1 parent efa5c14
@soulcutter soulcutter authored myronmarston committed
View
1  lib/rspec/core/example_group.rb
@@ -362,6 +362,7 @@ def self.run(reporter)
results_for_descendants = children.ordered.map {|child| child.run(reporter)}.all?
result_for_this_group && results_for_descendants
rescue Exception => ex
+ RSpec.wants_to_quit = true if fail_fast?
fail_filtered_examples(ex, reporter)
ensure
run_after_all_hooks(new)
View
22 spec/rspec/core/example_group_spec.rb
@@ -385,6 +385,15 @@ def metadata_hash(*args)
order.should eq([1,2,3])
end
+ it "does not set RSpec.wants_to_quit in case of an error in before all (without fail_fast?)" do
+ group = ExampleGroup.describe
+ group.before(:all) { raise "error in before all" }
+ group.example("example") {}
+
+ group.run
+ RSpec.wants_to_quit.should be_false
+ end
+
it "runs the before eachs in order" do
group = ExampleGroup.describe
order = []
@@ -820,9 +829,13 @@ def metadata_hash(*args)
let(:reporter) { double("reporter").as_null_object }
context "with fail_fast? => true" do
- it "does not run examples after the failed example" do
+ let(:group) do
group = RSpec::Core::ExampleGroup.describe
group.stub(:fail_fast?) { true }
+ group
+ end
+
+ it "does not run examples after the failed example" do
examples_run = []
group.example('example 1') { examples_run << self }
group.example('example 2') { examples_run << self; fail; }
@@ -832,6 +845,13 @@ def metadata_hash(*args)
examples_run.length.should eq(2)
end
+
+ it "sets RSpec.wants_to_quit flag if encountering an exception in before(:all)" do
+ group.before(:all) { raise "error in before all" }
+ example = group.example("equality") { 1.should eq(2) }
+ group.run.should be_false
+ RSpec.wants_to_quit.should be_true
+ end
end
context "with RSpec.wants_to_quit=true" do
Please sign in to comment.
Something went wrong with that request. Please try again.