File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -441,11 +441,15 @@ def run_after_example
441
441
end
442
442
443
443
def verify_mocks
444
- @example_group_instance . verify_mocks_for_rspec
444
+ @example_group_instance . verify_mocks_for_rspec if mocks_need_verification?
445
445
rescue Exception => e
446
446
set_exception ( e )
447
447
end
448
448
449
+ def mocks_need_verification?
450
+ exception . nil? || execution_result . pending_fixed?
451
+ end
452
+
449
453
def assign_generated_description
450
454
if metadata [ :description ] . empty? && ( description = generate_description )
451
455
metadata [ :description ] = description
Original file line number Diff line number Diff line change @@ -723,22 +723,19 @@ def expect_pending_result(example)
723
723
expect ( ex ) . to fail_with ( RSpec ::Mocks ::MockExpectationError )
724
724
end
725
725
726
- context "when the example has already failed" do
727
- it 'appends the mock error to a `MultipleExceptionError` so the user can see both' do
728
- ex = nil
729
- boom = StandardError . new ( "boom" )
730
-
731
- RSpec . describe do
732
- ex = example do
733
- dbl = double
734
- expect ( dbl ) . to receive ( :Foo )
735
- raise boom
736
- end
737
- end . run
726
+ it 'skips mock verification if the example has already failed' do
727
+ ex = nil
728
+ boom = StandardError . new ( "boom" )
738
729
739
- expect ( ex . exception ) . to be_a ( RSpec ::Core ::MultipleExceptionError )
740
- expect ( ex . exception . all_exceptions ) . to match [ boom , an_instance_of ( RSpec ::Mocks ::MockExpectationError ) ]
741
- end
730
+ RSpec . describe do
731
+ ex = example do
732
+ dbl = double
733
+ expect ( dbl ) . to receive ( :Foo )
734
+ raise boom
735
+ end
736
+ end . run
737
+
738
+ expect ( ex . exception ) . to be boom
742
739
end
743
740
744
741
it 'allows `after(:example)` hooks to satisfy mock expectations, since examples are not complete until their `after` hooks run' do
You can’t perform that action at this time.
0 commit comments