Ruby on rails 尝试加载gem时出错';工厂女孩轨道;。(绑定器::GemRequireError)
我无法加载gem factory\u girl\u rails来正确运行测试。 我到处都查过了,但我解决不了。 以下是我运行Ruby on rails 尝试加载gem时出错';工厂女孩轨道;。(绑定器::GemRequireError),ruby-on-rails,ruby,rubygems,factory-bot,Ruby On Rails,Ruby,Rubygems,Factory Bot,我无法加载gem factory\u girl\u rails来正确运行测试。 我到处都查过了,但我解决不了。 以下是我运行spec时的错误: /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'fa
spec
时的错误:
/Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'factory_girl_rails'. (Bundler::GemRequireError)
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /Users/qcherifi/Documents/perso/wan/wannatalk.io/config/application.rb:7:in `<top (required)>'
from /Users/qcherifi/Documents/perso/wan/wannatalk.io/config/environment.rb:2:in `require'
from /Users/qcherifi/Documents/perso/wan/wannatalk.io/config/environment.rb:2:in `<top (required)>'
from /Users/qcherifi/Documents/perso/wan/wannatalk.io/spec/spec_helper.rb:2:in `require'
from /Users/qcherifi/Documents/perso/wan/wannatalk.io/spec/spec_helper.rb:2:in `<top (required)>'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:1295:in `require'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:1295:in `block in requires='
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:1295:in `each'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:1295:in `requires='
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:108:in `each'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:21:in `configure'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:105:in `setup'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:92:in `run'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:78:in `run'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.3/exe/rspec:4:in `<top (required)>'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `load'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `<main>'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/qcherifi/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
/规格/型号/参与者规格rb
require 'spec_helper'
RSpec.describe Participant, type: :model do
it "has a valid factory"
Factory.create(:participant).should be_valid
it "is invalid without a name"
it "returns a participant's full name as a string"
end
/spec/factories/participants.rb
需要“冒牌货”
FactoryGirl.define do
factory :participant do |f|
f.name {Faker::Name.name}
f.email {Faker::Internet.email}
f.password {Faker::Internet.password(8)}
end
end
我以前遇到过此问题,导致此错误的原因可能有三个:
您需要先在平台上安装Nodejs。@BilalMaqsood感谢您的反应。我安装了node js,再次绑定并运行spec,但它仍然没有运行尝试此操作,而不是在gem文件中使用
gem'factory\u girl\u rails'
使用gem'factory\u girl'
我刚刚发现问题。。。这是一个愚蠢的错误,我创建了两个文件/support/factory_girl.rb。现在它工作了!
FactoryGirl.define do
factory :participant do |f|
f.name {Faker::Name.name}
f.email {Faker::Internet.email}
f.password {Faker::Internet.password(8)}
end
end