Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Created December 14, 2010 17:52
Show Gist options
  • Save MarkMenard/740783 to your computer and use it in GitHub Desktop.
Save MarkMenard/740783 to your computer and use it in GitHub Desktop.
# My first attempt at using both Mocha and RSpec mocks in a project.
module Spec
module Adapters
module MockFramework
# Mocha::Standalone was deprecated as of Mocha 0.9.7.
begin
include Mocha::API
rescue NameError
include Mocha::Standalone
end
include Spec::Mocks::ExampleMethods
def setup_mocks_for_rspec
mocha_setup
$rspec_mocks ||= Spec::Mocks::Space.new
end
def verify_mocks_for_rspec
mocha_verify
$rspec_mocks.verify_all
end
def teardown_mocks_for_rspec
mocha_teardown
$rspec_mocks.reset_all
end
end
end
end
@MarkMenard
Copy link
Author

The other thing I thought about was aliasing the mocha #mock, #stub, etc. methods to mocha_mock# or some such convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment