]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/pure/mocking_example.rb
6adbef59d09963cd96e7565788f5c3ad6a641ff3
[rails.git] / vendor / gems / rspec-1.1.2 / examples / pure / mocking_example.rb
1 require File.dirname(__FILE__) + '/spec_helper'
2
3 describe "A consumer of a mock" do
4   it "should be able to send messages to the mock" do
5     mock = mock("poke me")
6     mock.should_receive(:poke)
7     mock.poke
8   end
9 end
10
11 describe "a mock" do
12   it "should be able to mock the same message twice w/ different args" do
13     mock = mock("mock")
14     mock.should_receive(:msg).with(:arg1).and_return(:val1)
15     mock.should_receive(:msg).with(:arg2).and_return(:val2)
16     mock.msg(:arg1).should eql(:val1)
17     mock.msg(:arg2).should eql(:val2)
18   end
19
20   it "should be able to mock the same message twice w/ different args in reverse order" do
21     mock = mock("mock")
22     mock.should_receive(:msg).with(:arg1).and_return(:val1)
23     mock.should_receive(:msg).with(:arg2).and_return(:val2)
24     mock.msg(:arg2).should eql(:val2)
25     mock.msg(:arg1).should eql(:val1)
26   end
27 end