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

Version Path
rspec-mocks-2.0.1 README.markdown
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.3.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.2.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.1.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.1.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.1.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
gemrage-0.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/README.markdown
rspec-mocks-2.0.0 README.markdown
rspec-mocks-2.0.0.rc README.markdown
rspec-mocks-2.0.0.beta.22 README.markdown
rspec-mocks-2.0.0.beta.20 README.markdown
rspec-mocks-2.0.0.beta.19 README.markdown
rspec-mocks-2.0.0.beta.18 README.markdown
rspec-mocks-2.0.0.beta.17 README.markdown