Sha256: 65ac3fbc1e156992236a7cbee9bd69dcc5fd97d50404f1da206cd2ab8c6592d2
Contents?: true
Size: 1.13 KB
Versions: 12
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' module Rspec module Mocks describe "mock failure" 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(Rspec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")}) m.bar("message") # allows the spec to pass end pending "should tell you when it receives the right message with the wrong args if you stub the method (fix bug 15719)" do # NOTE - for whatever reason, if you use a the block style of pending here, # rcov gets unhappy. Don't know why yet. m = mock("foo") m.stub!(:bar) m.should_receive(:bar).with("message") lambda { m.bar("different message") }.should raise_error(Rspec::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
Version data entries
12 entries across 12 versions & 1 rubygems