rspec-core icon indicating copy to clipboard operation
rspec-core copied to clipboard

failed expectations in before :all hook do not set rspec exit code to 1

Open marckubischta opened this issue 15 years ago • 3 comments

Given the following example_spec.rb:

describe "Failing before all hook" do
  before :all do
    nil.should be_true
  end
  it "should report a failure" do
    true.should be_true
  end
end

When I run the command:

  rspec example_spec.rb; echo "exit code is:" $?

Then the result is:

F

Failures:

  1) Failing before all hook should report a failure
     Failure/Error: nil.should be_true
       expected nil to be true
     # ./example_spec.rb:3:in `block (2 levels) in '

Finished in 0.00055 seconds
1 example, 1 failure
exit code is: 0

marckubischta avatar Apr 14 '11 22:04 marckubischta

This happens with rspec 2.4.0 as well as 2.5.1.

marckubischta avatar Apr 14 '11 22:04 marckubischta

I thought this might be related to the ruby fix for at_exit handler execution order (http://redmine.ruby-lang.org/issues/show/4400 which was fixed in rev 30888) but it occurs in ruby 1.9.2p0 (2010-08-18 revision 29036) as well as ruby 1.9.2p180 (2011-02-18 revision 30909).

marckubischta avatar Apr 14 '11 23:04 marckubischta

I just found closed issue 301 which is functionally equivalent; closing.

marckubischta avatar Apr 15 '11 18:04 marckubischta