Using RSpec stubs and mocks in Cucumber
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.