Logo: Relish

  1. Sign in

Project: Rspec-mocks

Configuring responses

When allowing or expecting messages, the default response is to return nil. Several
methods are provided to configure how the test double responds to the message.

In addition, you can provide a block implementation to respond in any manner you wish.

Note: for simplicity, the examples here use allow rather than expect, but these APIs apply equally to both cases.


  1. Returning a value
  2. Raising an error
  3. Throwing
  4. Yielding
  5. Calling the original implementation
  6. Block implementation

Last published about 6 years ago by Pritesh Jain.