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
When using stub_const, it does not reset Object.const_source_location after example finished.
Your environment
Ruby version: 2.7.5, 3.2.2
rspec-mocks version: 3.12.6
Steps to reproduce
File: spec/foo_spec.rb
classFoo;endRSpec.describeFoodoit'stubs and can be reset'dostub_const('Foo',Class.new)expect(Object.const_source_location('Foo').first).not_toinclude('foo_spec.rb')RSpec::Mocks.space.reset_allexpect(Object.const_source_location('Foo').first).toinclude('foo_spec.rb')endend
Expected behavior
Expect above test to pass.
Actual behavior
Foo
stubs and can be reset (FAILED - 1)
Failures:
1) Foo stubs and can be reset
Failure/Error: expect(Object.const_source_location('Foo').first).to include('foo_spec.rb')
expected "/Users/wei-fun.chang/workspace/rspec-mocks/lib/rspec/mocks/mutate_const.rb" to include "foo_spec.rb"
...
The text was updated successfully, but these errors were encountered:
We have a code owner trace lib based on Object.const_source_location to map the code owner through the file path where the original class was defined. Recently there is a test flake caused by not able to pin down the owner because of source location changed to rspec-mock.
I'm not sure theres much we can do about that, given that the location of this is set by Ruby, we don't really have an alternate way to set constants that I know of, I would suggest you need to rework your tests to avoid using stub_const (or stub out const_source_location to remove the mock locations) sorry 😞
Subject of the issue
When using
stub_const
, it does not resetObject.const_source_location
after example finished.Your environment
Steps to reproduce
File:
spec/foo_spec.rb
Expected behavior
Expect above test to pass.
Actual behavior
The text was updated successfully, but these errors were encountered: