[英]RSpec error “Uninitialized constant FactoryGirl (Name Error)”
I try running my RSpec test: 我尝试运行我的RSpec测试:
rspec comments.rb
but keep getting the same error (see title). 但不断得到同样的错误(见标题)。 Before anyone asks I have already added
require factory_girl
to spec_helper.rb. 之前有人问我已经添加
require factory_girl
到spec_helper.rb。
The contents of spec/factories/comments.rb
file are: spec/factories/comments.rb
文件的内容是:
FactoryGirl.define do
factory :comment do
comment "MyString"
task_id 1
end
end
Here is testing group of the gemfile where I included factory_girl_rails: 这是gemfile的测试组,其中包含了factory_girl_rails:
source 'http://rubygems.org'
...
group :development, :test do
gem 'debugger'
gem 'factory_girl_rails'
gem 'rspec-rails'
end
...
您只需在spec_helper.rb文件中添加以下内容即可
require 'factory_girl_rails'
做这个:
FactoryGirl.create(:artist).should be_valid
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.