Sha256: 93247c5d666a7b15895591f517c70ee5193d3a8e116770c9cafe3c12505bd89e
Contents?: true
Size: 1.35 KB
Versions: 8
Compression:
Stored size: 1.35 KB
Contents
# RSpec Mocks rspec-mocks provides a test-double framework for rspec including support for method stubs, fakes, and message expectations. ## Documentation * [Cucumber features](http://relishapp.com/rspec/rspec-mocks/v/2-0) * [RDoc](http://rubydoc.info/gems/rspec-mocks/2.0.1/frames) ## Install gem install rspec # for rspec-core, rspec-expectations, rspec-mocks gem install rspec-mocks # for rspec-mocks only ## 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
8 entries across 8 versions & 2 rubygems