You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mocking framework appears to not be initialized properly before the example is run in an around block.
RSpec.configure do |config|
config.mock_with :rspec
end
describe 'around mocking' do
let!(:now) { Time.now }
around(:each) do |example|
Time.stub(:now).and_return(now)
example.run
end
specify { Time.now.should == now }
end
This results in the following failure:
Run filtered
F
Failures:
1) around mocking
Failure/Error: Time.stub(:now).and_return(now)
NoMethodError:
undefined method `stub' for Time:Class
# ./bug.rb:9
Finished in 0.00039 seconds
1 example, 1 failure
Changing the around to a before works as expected, and after example.run is called, the mocking methods are available inside the around block. It appears the source of the the bug is that RSpec::Core::Example#run_before_each is where the mocking framework is set up (@example_group_instance.setup_mocks_for_rspec), but around begins executing before this code is called.
The text was updated successfully, but these errors were encountered:
The mocking framework appears to not be initialized properly before the example is run in an
around
block.This results in the following failure:
Changing the
around
to abefore
works as expected, and afterexample.run
is called, the mocking methods are available inside thearound
block. It appears the source of the the bug is thatRSpec::Core::Example#run_before_each
is where the mocking framework is set up (@example_group_instance.setup_mocks_for_rspec
), butaround
begins executing before this code is called.The text was updated successfully, but these errors were encountered: