class RSpec::Core::Configuration
def mock_with(framework)
teardown_mocks_for_rspec
when expectations fail
- called after each example. Framework should raise an exception
verify_mocks_for_rspec
- called before each example
setup_mocks_for_rspec
should adhere to RSpec's mock framework adapter API:
Given a Module, includes that module in every example group. The module
mocking framework to save a little bit of overhead.
Given :nothing, configures no framework. Use this if you don't use any
framework.
Given any of :rspec, :mocha, :flexmock, or :rr, configures the named
`framework` can be a Symbol or a Module.
Sets the mock framework adapter module.
def mock_with(framework) framework_module = case framework when Module framework when String, Symbol require case framework.to_s when /rspec/i 'rspec/core/mocking/with_rspec' when /mocha/i 'rspec/core/mocking/with_mocha' when /rr/i 'rspec/core/mocking/with_rr' when /flexmock/i 'rspec/core/mocking/with_flexmock' else 'rspec/core/mocking/with_absolutely_nothing' end RSpec::Core::MockFrameworkAdapter end new_name, old_name = [framework_module, @mock_framework].map do |mod| mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed end unless new_name == old_name assert_no_example_groups_defined(:mock_framework) end @mock_framework = framework_module end