我是factory_girl gem的新手。我的Ruby gem具有静态的clientid,会话和主机。
我的工厂代码就像
FactoryGirl.define do
factory :session do |f|
f.clientid "clientid string"
f.secret " secret string"
f.host "host string"
end
end
我的规范代码就像
describe '#new' do
it 'works' do
result = FactoryGirl.build(clientid, secret, host)
expect(result).not_to be_nil
end
end
我的spec_helper文件是
require 'rspec'
require 'factory_girl'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'mydemogem'
我正试图为此建立一个工厂。但这给了我以下错误:
undefined local variable or method `clientid' for #<RSpec::ExampleGroups::
您的规格有
result = FactoryGirl.build(clientid, secret, host)
但你没有定义clientid
,secret
和host
。您无法访问未定义的变量
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句