How to experiment with rspec from within irb

irb, mocking, rspec

Solution

You can play around with RSpec test doubles in `irb` by requiring `"rspec/mocks/standalone"`:

$ irb
> require 'rspec/mocks/standalone'
> b = double("book")
  =>  #<RSpec::Mocks::Mock:0x3fd88d0157e8 @name="book">

Problem

For example, I want to say b = double("book") in irb and play with the result. In irb if I say ``` require 'rspec' b = double("book") ``` I get an error. Ideas?

Original source