changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/failing_examples/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 "Mocker" do
4
5 it "should be able to call mock()" do
6 mock = mock("poke me")
7 mock.should_receive(:poke)
8 mock.poke
9 end
10
11 it "should fail when expected message not received" do
12 mock = mock("poke me")
13 mock.should_receive(:poke)
14 end
15
16 it "should fail when messages are received out of order" do
17 mock = mock("one two three")
18 mock.should_receive(:one).ordered
19 mock.should_receive(:two).ordered
20 mock.should_receive(:three).ordered
21 mock.one
22 mock.three
23 mock.two
24 end
25
26 it "should get yelled at when sending unexpected messages" do
27 mock = mock("don't talk to me")
28 mock.should_not_receive(:any_message_at_all)
29 mock.any_message_at_all
30 end
31
32 it "has a bug we need to fix" do
33 pending "here is the bug" do
34 # Actually, no. It's fixed. This will fail because it passes :-)
35 mock = mock("Bug")
36 mock.should_receive(:hello)
37 mock.hello
38 end
39 end
40end