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...
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/68928338-36a4-472c-8dd5-f685613e6750%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.