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