To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!More about adding a collaborator
allow a message on any instance of a class
allow_any_instance_of(Class).to receive when you want to configure how
instances of the given class respond to a message without setting an
expectation that the message will be received.
- allowing a message on any instance of a class
a file named "example_spec.rb" with:
describe "any_instance.should_receive" do before do allow_any_instance_of(Object).to receive(:foo).and_return(:return_value) end it "allows any instance of the class to receive the message" do o = Object.new expect(o.foo).to eq(:return_value) end it "passes even if no instances receive that message" do o = Object.new end end
- the examples should all pass
Last published over 6 years ago by myronmarston.
RSpec Mocks settings