[英]RSpec error “Uninitialized constant FactoryGirl (Name Error)”
我尝试运行我的RSpec测试:
rspec comments.rb
但不断得到同样的错误(见标题)。 之前有人问我已经添加require factory_girl
到spec_helper.rb。
spec/factories/comments.rb
文件的内容是:
FactoryGirl.define do
factory :comment do
comment "MyString"
task_id 1
end
end
这是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.