简体   繁体   中英

RSpec mock from test console

I want to test out RSpec stubbing and mocking from a rails test console . Is it possible ? If yes , how ?

This is what I tried :

$rails c test
>require "./spec/spec_helper"
true
>source = double('source')
NoMethodError: undefined method `double' for main:Object

您需要require 'rspec/mocks/standalone' ,如文档中所述

试试这个:

$ RAILS_ENV=test rails c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM