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
expect a message on any instance of a class
expect_any_instance_of(Class).to receive to set an expectation that one
(and only one) instance of a class receives a message before the example is
completed. The spec will fail if no instance receives a message.
- expect a message on any instance of a class
a file named "example_spec.rb" with:
describe "expect_any_instance_of" do before do expect_any_instance_of(Object).to receive(:foo).and_return(:return_value) end it "verifies that one instance of the class receives the message" do o = Object.new expect(o.foo).to eq(:return_value) end it "fails unless an instance receives that message" do o = Object.new end end
- the output should contain "2 examples, 1 failure"
- the output should contain "1) expect_any_instance_of fails unless an instance receives that message"
Last published almost 7 years ago by myronmarston.
RSpec Mocks settings