]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/pure/partial_mock_example.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / examples / pure / partial_mock_example.rb
1 require File.dirname(__FILE__) + '/spec_helper'
2
3 class MockableClass
4   def self.find id
5     return :original_return
6   end
7 end
8
9 describe "A partial mock" do
10
11   it "should work at the class level" do
12     MockableClass.should_receive(:find).with(1).and_return {:stub_return}
13     MockableClass.find(1).should equal(:stub_return)
14   end
15
16   it "should revert to the original after each spec" do
17     MockableClass.find(1).should equal(:original_return)
18   end
19
20   it "can be mocked w/ ordering" do
21     MockableClass.should_receive(:msg_1).ordered
22     MockableClass.should_receive(:msg_2).ordered
23     MockableClass.should_receive(:msg_3).ordered
24     MockableClass.msg_1
25     MockableClass.msg_2
26     MockableClass.msg_3
27   end
28 end