changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/mocks/bug_report_15719_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3module Spec
4 module Mocks
5 describe "mock failure" do
6
7 it "should tell you when it receives the right message with the wrong args" do
8 m = mock("foo")
9 m.should_receive(:bar).with("message")
10 lambda {
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
14 end
15
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.
20 m = mock("foo")
21 m.stub!(:bar)
22 m.should_receive(:bar).with("message")
23 lambda {
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
27 end
28 end
29 end
30end