[rspec-devel] [ rspec-Bugs-15719 ] when a method is stubbed and then mocked, error message is misleading

noreply at rubyforge.org noreply at rubyforge.org
Sun Nov 18 12:36:01 EST 2007


Bugs item #15719, was opened at 2007-11-18 17:36
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15719&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: Nobody (None)
Summary: when a method is stubbed and then mocked, error message is misleading

Initial Comment:
module Spec
  module Mocks
    describe "mock failure when the mock receives the right message with the wrong args" do
      it "should tell you when it receives the right message with the wrong args" do
        m = mock("foo")
        m.should_receive(:bar).with("message")
        lambda {
          m.bar("different message")
        }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")})
        m.bar("message") # allows the spec to pass
      end

      it "should tell you when it receives the right message with the wrong args if you stub the method" do
        pending("fix bug") do
          m = mock("foo")
          m.stub!(:bar)
          m.should_receive(:bar).with("message")
          lambda {
            m.bar("different message")
          }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")})
          m.bar("message") # allows the spec to pass
        end
      end
    end
  end
end

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15719&group_id=797


More information about the rspec-devel mailing list