我已经安装了 shoulda 和 factory_girl,我可以很好地运行 shoulda,但是当我添加这个时:
require 'factory_girl'
Factory.define :user do |u|
u.mail 'test@example.com'
u.pass 'secret'
end
到我的 test/test_helper.rb 我收到这个错误:
/test/test_helper.rb:1:in `require': 没有要加载的文件 -- factory_girl (LoadError)
当我执行 rake test:units
我已经使用以下方法安装了两个 gem:
sudo gem installthoughtbot-should --source= http://gems.github.com sudo gem installthoughtbot-factory_girl --source= http://gems.github.com
并且可以看到它们都安装得很好。
- 顺便说一句,这也很好用:
脚本/控制台加载开发环境(Rails 2.3.8)
需要'factory_girl' => []
所以要求宝石似乎有效