Sha256: 499255155b018da503e9519f609694d016076860191cc9d500a46696bda11545

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 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       # 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

## 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

11 entries across 11 versions & 3 rubygems

Version Path
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/README.md
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/README.md
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-mocks-2.7.0/README.md
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-mocks-2.7.0/README.md
rspec-mocks-2.8.0.rc1 README.md
rspec-mocks-2.7.0 README.md