工厂未注册错误
Factory not registered error
我对 Factory Girl 有疑问 gem:
使用我的 spec_helper.rb 代码中的行:
require 'factory_girl_rails'
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
我有错误:
ArgumentError:
Factory not registered: products
Ps: 文件spec/factories/products.rb
已经存在
如果我注释这些行,错误会更改为:
NoMethodError: undefined method `create_list'
我在文件中使用的方法create_list products_controller_spec.rb
:
describe "GET #index" do
let(:my_products){ create_list(:products, 10) }
spec/factories/products.rb
FactoryGirl.define do
factory :product do
name "MyString"
description "MyString"
price "10.5"
maker "MyString"
end
end
我哪里做错了?
厂名product
。尝试:
let(:my_products) { create_list(:product, 10) }
我对 Factory Girl 有疑问 gem:
使用我的 spec_helper.rb 代码中的行:
require 'factory_girl_rails'
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
我有错误:
ArgumentError:
Factory not registered: products
Ps: 文件spec/factories/products.rb
已经存在
如果我注释这些行,错误会更改为:
NoMethodError: undefined method `create_list'
我在文件中使用的方法create_list products_controller_spec.rb
:
describe "GET #index" do
let(:my_products){ create_list(:products, 10) }
spec/factories/products.rb
FactoryGirl.define do
factory :product do
name "MyString"
description "MyString"
price "10.5"
maker "MyString"
end
end
我哪里做错了?
厂名product
。尝试:
let(:my_products) { create_list(:product, 10) }