Logo: Relish

  1. Sign in

Project: RSpec Mocks 3.12

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. Wrapping the original implementation
  7. Block implementation
  8. Mixed responses

Last published 3 months ago by Jon Rowe.