Mocha with Cucumber
For most cases, you shouldn’t need to use mocking and stubbing with Cucumber. However, there are certain cases in which you need to write stories to work around external services (such as OpenID logins or Paypal transactions.) Mocha makes it dirt simple to write around those services, but it’s not included in the Cucumber setup.
Simply create the file mocha.rb in your features/setup folder and paste this coe. You can now use mocks in your steps.
View as text
## features/support/mocha.rb
require "mocha"
World(Mocha::Standalone)
Before do
mocha_setup
end
After do
begin
mocha_verify
ensure
mocha_teardown
end
end