We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class SomeClass def print_hello puts "Hello" end end RSpec.describe do specify do object = SomeClass.new expect(object).to receive(:print_hello) do expect(true).to be_false end.and_call_original object.print_hello end end
This test will always be passed (same issue for RSpec2). I found only one way to correctly run similar tests:
object = SomeClass.new method = object.method(:print_hello) expect(object).to receive(:print_hello) do expect(true).to be_false method.call end object.print_hello
Version with expect_any_instance_of:
expect_any_instance_of
object = SomeClass.new method = SomeClass.instance_method(:print_hello) expect_any_instance_of(SomeClass).to receive(:print_hello) do |obj| expect(true).to be_false method.bind(obj).call end object.print_hello
The text was updated successfully, but these errors were encountered:
Opps, it duplicates #382. Sorry.
Sorry, something went wrong.
No branches or pull requests
This test will always be passed (same issue for RSpec2). I found only one way to correctly run similar tests:
Version with
expect_any_instance_of
:The text was updated successfully, but these errors were encountered: