Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 355 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Specify that an object doesn't receive any messages in RSpec

#1
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
Reply

#2
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())
Reply

#3
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
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through