Sha256: 9424f9846a984f6aec819118656ff06ddf00412cc420e22daed4bda9288dbe64
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 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 double = double("foo") double.should_receive(:bar).with("message") lambda { double.bar("different message") }.should raise_error(Rspec::Mocks::MockExpectationError, %Q{Double "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")}) double.rspec_reset # so the example doesn't fail 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. double = double("foo") double.stub(:bar) double.should_receive(:bar).with("message") lambda { double.bar("different message") }.should raise_error(Rspec::Mocks::MockExpectationError, %Q{Double 'foo' expected :bar with ("message") but received it with ("different message")}) double.rspec_reset # so the example doesn't fail end end end end
Version data entries
4 entries across 4 versions & 1 rubygems