Questions tagged «shoulda»

10
如何在测试环境中运行Rails控制台并加载test_helper.rb?
背景:Thoughtbot的“ Factory Girl” gem存在一些问题,它用于创建在单元测试和其他测试中使用的对象。我想转到控制台并运行不同的Factory Girl呼叫,以查看发生了什么情况。例如,我想去那里做... >> Factory(:user).inspect 我知道您可以在不同的环境中运行控制台... $脚本/控制台RAILS_ENV = test 但是当我这样做时,Factory类不可用。好像test_helper.rb没有加载。 我尝试了各种require呼叫,包括具有绝对路径的呼叫,test_helper.rb但与此类似,它们失败了: $ 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 r 啊
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.