0

Rails3.2.8にある新しいプロジェクトでFactory_girl_railsを使用しています。上記のエラーが発生します。誰か私に何をすべきか提案してもらえますか?

/home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- /home/sandhya/robly/spec/factories (LoadError)
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /home/sandhya/robly/spec/spec_helper.rb:6:in `<top (required)>'
    from /home/sandhya/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/sandhya/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/sandhya/robly/spec/models/address_spec.rb:1:in `<top (required)>'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /home/sandhya/.rvm/gems/ruby-1.9.3-p0@robly/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

私のgemfileは次のようになります:

グループ :

test do
  gem 'rspec-rails'
  gem "factory_girl_rails"
  gem "capybara"
end

そして私のfactories.rbで私は持っています

FactoryGirl.define do
  factory :address do |v|
    v.email "test@email.com"
    v.state "Karnataka"
    v.country "India"
    v.zip_code "560061"
    v.office_mobiel "9999999999"
    v.company "Some Company"
    v.city "Bangalore"
  end
end
4

2 に答える 2

0

通常、FactoryGirl は自分で factory.rb をロードする必要があります。しかし、spec_helper.rb ファイルに FactoryGirl を含めましたか?

はいの場合、少なくともスタックトレースに記載されている 2 つのファイルの内容である /spec/spec_helper.rb と /spec/models/address_spec.rb の詳細情報が必要になります。

于 2012-11-01T12:11:41.147 に答える