Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (33 sloc) 1.218 kb
daa9b05 @dchelimsky change top-level module from Rspec to RSpec
dchelimsky authored
1 # RSpec Mocks
f9f8418 @dchelimsky words
dchelimsky authored
2
3 rspec-mocks provides a test-double framework for rspec including support
4 for method stubs, fakes, and message expectations.
5
6 ## Install
7
f26af00 @dchelimsky words
dchelimsky authored
8 gem install rspec --prerelease
f9f8418 @dchelimsky words
dchelimsky authored
9
10 This will install rspec, rspec-core, rspec-expectations and rspec-mocks.
d5a1da7 @spicycode Initial jeweler repository creation
spicycode authored
11
f26af00 @dchelimsky words
dchelimsky authored
12 ## Method Stubs
13
14 describe "consumer" do
15 it "gets stuff from a service" do
16 service = double('service')
17 service.stub(:find) { 'value' }
18 consumer = Consumer.new(service)
19 consumer.consume
20 consumer.aquired_stuff.should eq(['value'])
21 end
22 end
23
24 ## Message Expectations
25
26 describe "some action" do
27 context "when bad stuff happens" do
28 it "logs the error" do
29 logger = double('logger')
30 doer = Doer.new(logger)
31 logger.should_receive(:log).with('oops')
32 doer.do_something_with(:bad_data)
33 end
34 end
35 end
9d19ca0 @dchelimsky update readme
dchelimsky authored
36
f26af00 @dchelimsky words
dchelimsky authored
37 ## Contribute
38
39 See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
40
41 ## Also see
9d19ca0 @dchelimsky update readme
dchelimsky authored
42
f9f8418 @dchelimsky words
dchelimsky authored
43 * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
44 * [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)
45 * [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
Something went wrong with that request. Please try again.