method

mock_with

Importance_2
mock_with(mock_framework) public

Chooses what mock framework to use. Example:

  Spec::Runner.configure do |config|
    config.mock_with :rspec, :mocha, :flexmock, or :rr
  end

To use any other mock framework, you’ll have to provide your own adapter. This is simply a module that responds to the following methods:

  setup_mocks_for_rspec
  verify_mocks_for_rspec
  teardown_mocks_for_rspec.

These are your hooks into the lifecycle of a given example. RSpec will call setup_mocks_for_rspec before running anything else in each Example. After executing the #after methods, RSpec will then call verify_mocks_for_rspec and teardown_mocks_for_rspec (this is guaranteed to run even if there are failures in verify_mocks_for_rspec).

Once you’ve defined this module, you can pass that to mock_with:

  Spec::Runner.configure do |config|
    config.mock_with MyMockFrameworkAdapter
  end
Show source
Register or log in to add new notes.