changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/examples/pure/mocking_example.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'
2
3describe "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
9end
10
11describe "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
27end