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
{{ message }}
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
expect_any_instance_of(…).not_to receive(…) or expect_any_instance_of(…).to receive(…) make a private instance method public. expect(…).not_to receive(…) and expect(…).not_to receive(…) work as intended.
Your environment
Ruby versions: 2.3.8, 2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.4, 3.3.4 (for the latter, the reproducer script has to be changed slightly to account for the changed NoMethodError message)
rspec-mocks version: 3.13.1
Steps to reproduce
Run the following script.
# frozen_string_literal: truebeginrequire"bundler/inline"rescueLoadError=>e
$stderr.puts"Bundler version 1.10 or later is required. Please update your Bundler"raiseeendgemfile(true)dosource"https://rubygems.org"gem"rspec","3.13.0"# Activate the gem and version you are reporting the issue against.endputs"Ruby version is: #{RUBY_VERSION}"require'rspec/autorun'RSpec.describe'a private method'dolet(:klass)doClass.newdoprivatedefdefined_private_methodendendendlet(:object){klass.new}shared_examples'behaves like a private method'doit'can’t be called from the outside'doexpect{object.defined_private_method}.toraise_error"private method `defined_private_method' called for #{object}"endit'is included in the list of private methods'doexpect(object.private_methods).toinclude:defined_private_methodendit'is not included in the list of public methods'doexpect(object.public_methods).not_toinclude:defined_private_methodendendcontext'that is not mocked'doinclude_examples'behaves like a private method'endcontext'mocked with #expect'dobeforedoexpect(object).not_toreceive(:defined_private_method)endinclude_examples'behaves like a private method'endcontext'mocked with #expect_any_instance_of'dobeforedoexpect_any_instance_of(klass).not_toreceive(:defined_private_method)endinclude_examples'behaves like a private method'endend
Expected behavior
There should be no failures.
Actual behavior
All examples in context 'mocked with #expect_any_instance_of' fail.
The text was updated successfully, but these errors were encountered:
Subject of the issue
expect_any_instance_of(…).not_to receive(…)
orexpect_any_instance_of(…).to receive(…)
make a private instance method public.expect(…).not_to receive(…)
andexpect(…).not_to receive(…)
work as intended.Your environment
Steps to reproduce
Run the following script.
Expected behavior
There should be no failures.
Actual behavior
All examples in context
'mocked with #expect_any_instance_of'
fail.The text was updated successfully, but these errors were encountered: