Sha256: 00e6607e897d8b6c83fbd15a137a0b78fb959655113a79f1aa8a87cfafb4443a
Contents?: true
Size: 1.19 KB
Versions: 19
Compression:
Stored size: 1.19 KB
Contents
# RSpec Mocks rspec-mocks provides a test-double framework for rspec including support for method stubs, fakes, and message expectations. ## Install gem install rspec --prerelease This will install rspec, rspec-core, rspec-expectations and rspec-mocks. ## Method Stubs describe "consumer" do it "gets stuff from a service" do service = double('service') service.stub(:find) { 'value' } consumer = Consumer.new(service) consumer.consume consumer.aquired_stuff.should eq(['value']) end end ## Message Expectations describe "some action" do context "when bad stuff happens" do it "logs the error" do logger = double('logger') doer = Doer.new(logger) logger.should_receive(:log).with('oops') doer.do_something_with(:bad_data) end end end ## Contribute See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev) ## Also see * [http://github.com/rspec/rspec](http://github.com/rspec/rspec) * [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core) * [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
Version data entries
19 entries across 19 versions & 2 rubygems