Logo: Relish

  1. Sign up
  2. Sign in

Project: RSpec Mocks 3.2

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.

Topics

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

Last published over 1 year ago by myronmarston.