12
我想從軌道測試控制檯測試RSpec存根和模擬。可能嗎 ?如果是,如何?從測試控制檯RSpec模擬
這是我的嘗試:
$rails c test
>require "./spec/spec_helper"
true
>source = double('source')
NoMethodError: undefined method `double' for main:Object
我想從軌道測試控制檯測試RSpec存根和模擬。可能嗎 ?如果是,如何?從測試控制檯RSpec模擬
這是我的嘗試:
$rails c test
>require "./spec/spec_helper"
true
>source = double('source')
NoMethodError: undefined method `double' for main:Object
你需要require 'rspec/mocks/standalone'
,爲stated in the documentation。
試試這個:
$ RAILS_ENV=test rails c
這相當於「rails c test」,我相信嗎? – Emil 2012-08-10 14:42:33
不幸的是:http://stackoverflow.com/questions/7668167/rails-console-test-loading-development-environment – Ch4rAss 2012-08-10 14:44:42