Hello,
I just had a false negative (test reported as OK while feature was actually broken) when expecting a method call on a nested service object because the method was private, but after applying an `expect_any_instance_of` the method call was made public and caused the test to pass (despite calling `and_call_original`
Here is a sample way to repro
class Foo
private
def method_meant_to_be_public
end
end
class FooJob < ActiveJob::Base
def perform
Foo.new.method_meant_to_be_public
end
end
Performing a FooJob indeed causes a crash with
private method `method_meant_to_be_public' called for #<Foo:0x00000003f58c98>
However my spec was, on first sight, not failing
describe FooJob do
it 'triggers warmup failure for the pro' do
expect_any_instance_of(Foo).to receive(:method_meant_to_be_public).and_call_original
FooJob.perform_now
end
end
I am wondering if this is expected behavior or if I should report it as a bug ? It is not really obvious that using expect_any_instance_of would override the public/private status of methods...