All,
Inspired by a conversation on the mocha list, I added the ability to
mix stubs w/ mocks on the same methods.
Here''s what it allows:
context "a mock" do
specify "can stub! and mock the same message" do
mock = mock("stubbing mock")
mock.stub!(:msg).and_return(:stub_value)
mock.should_receive(:msg).with(:arg).and_return(:mock_value)
mock.msg.should_equal :stub_value
mock.msg(:other_arg).should_equal :stub_value
mock.msg(:arg).should_equal :mock_value
mock.msg(:another_arg).should_equal :stub_value
mock.msg(:yet_another_arg).should_equal :stub_value
mock.msg.should_equal :stub_value
end
end
Basically, the stub will be invoked for any calls to :msg without :arg.
Does this seem useful? Check out the trunk if you think so and give it a shot.
Thanks,
David