1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe "mock failure" do
7 it "should tell you when it receives the right message with the wrong args" do
9 m.should_receive(:bar).with("message")
11 m.bar("different message")
12 }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")})
13 m.bar("message") # allows the spec to pass
16 it "should tell you when it receives the right message with the wrong args if you stub the method" do
17 pending("fix bug 15719")
18 # NOTE - for whatever reason, if you use a the block style of pending here,
19 # rcov gets unhappy. Don't know why yet.
22 m.should_receive(:bar).with("message")
24 m.bar("different message")
25 }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")})
26 m.bar("message") # allows the spec to pass