views:

495

answers:

1

I have installed both shoulda and factory_girl, I can run shoulda just fine, but when I add this:

require 'factory_girl'

Factory.define :user do |u|
  u.mail '[email protected]'
  u.pass 'secret'
end

to my test/test_helper.rb I'm getting this error:

/test/test_helper.rb:1:in `require': no such file to load -- factory_girl (LoadError)

when I execute rake test:units

I have installed both gems using:

sudo gem install thoughtbot-shoulda --source=http://gems.github.com sudo gem install thoughtbot-factory_girl --source=http://gems.github.com

and can see both of them being installed fine.

  • And by the way, this works fine as well:

script/console Loading development environment (Rails 2.3.8)

require 'factory_girl' => []

so requiring the gems seems to be working

+1  A: 

Couple things to check:

  • Don't use --source=http://gems.github.com anymore. This has been deprecated in favor for gemcutter.org
  • Don't use "thoughtbot-gem_name" - again this was deprecated by gemcutter.org. Just do sudo gem install factory_girl shoulda
  • Make sure you have config.gem 'factory_girl' in your config/environments/test.rb file.
rspeicher
hhhmm... I have added the line to my test.rb file and ran the gem install as you suggested, but now I'm getting ./test/test_helper.rb:3: uninitialized constant Factory (NameError) when I run the rake test:units command. I have removed the require statement from my test_helper file.
kristian nissen
I don't think you need to actually `require 'factory_girl'` anywhere as long as you have the config.gem line. So remove the require, and then move your Factory definitions out of test_helper.rb into a `test/factories.rb` file. This file gets parsed automatically by Factory Girl at runtime.
rspeicher
I did remove the require I only use config.gem 'factory_girl'
kristian nissen
I removed the entire project, uninstalled both gems and started over. It all seems to be working.
kristian nissen