Created
March 15, 2010 17:29
-
-
Save probablykabari/333081 to your computer and use it in GitHub Desktop.
rspec2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# line 16 | |
it "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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#line 411 | |
it "should temporarily replace a method stub on a mock" do | |
@mock.stub!(:msg).and_return(:stub_value) | |
@mock.should_receive(:msg).with(:arg).and_return(:mock_value) | |
@mock.msg(:arg).should equal(:mock_value) | |
@mock.msg.should equal(:stub_value) | |
@mock.msg.should equal(:stub_value) | |
@mock.rspec_verify | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# line 138 | |
it "should limit " do | |
@stub.stub!(:foo).with("bar") | |
@stub.should_receive(:foo).with("baz") | |
@stub.foo("bar") | |
@stub.foo("baz") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment