I know how to specify that an object shouldn't receive a specific message:
expect(File).to_not receive(:delete)
How would I specify that it shouldn't receive any messages at all? Something like
expect(File).to_not receive_any_message
Sounds like you just want to replace the object in question with a double on which you have defined no expectations (so any method call would result in an error). In your exact case you could do
stub_const("File", double())
I'm not sure what the use-case would be. But the following is the only direct answer I can come up with:
methods_list = File.public_methods # using 'public_methods' for clarity
methods_list.each do |method_name|
expect(File).to_not receive(method_name)
end
In case you want to cover all methods (i.e. not just the public
ones):
# readers, let me know if there is a single method to
# fetch all public, protected, and private methods
methods_list = File.public_methods +
File.protected_methods +
File.private_methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With