Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to experiment with rspec from within irb

Tags:

mocking

rspec

irb

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?

like image 323
pitosalas Avatar asked Feb 19 '13 23:02

pitosalas


1 Answers

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">
like image 58
Paul Fioravanti Avatar answered Oct 18 '22 09:10

Paul Fioravanti