The background: I'm having some problems with Thoughtbot's "Factory Girl" gem, with is used to create objects to use in unit and other tests. I'd like to go to the console and run different Factory Girl calls to check out what's happening. For example, I'd like to go in there are do...
>> Factory(:user).inspect
I know that you can run the console in different environments...
$ script/console RAILS_ENV=test
But when I do that, Factory class is not available. It looks as though test_helper.rb
is not getting loaded.
I tried various require
calls including one with the absolute path to test_helper.rb
but they fail similarly to this:
$ script/console RAILS_ENV=test
>> require '/Users/ethan/project/contactdb/test/test_helper.rb'
Errno::ENOENT: No such file or directory -
/Users/ethan/project/contactdb/config/environments/RAILS_ENV=test.rb
Grr. Argh.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…