Using RSpec stubs and mocks in Cucumber

Updated . Posted . Visible to the public.

By default, Cucumber uses mocha. This note shows to use RSpec stubs and mocks instead.

Rspec 1 / Rails 2

Put the following into your env.rb:

require 'spec/stubs/cucumber'

Rspec 2 / Rails 3

Put the following into your env.rb:

require 'cucumber/rspec/doubles'

Note: Since Cucumber 4 it is important to require these lines in the env.rb and not any other file in support/* to register the hooks after any other After hook in support/*. Otherwise your doubles are removed, while other After steps requires them to still be present, e.g. in Capybara::Lockstep.

Tobias Kraze
Last edit
Emanuel
Keywords
features, mock
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2010-09-09 14:07)