我尝试按照 RailsGuides instructions 运行一个简单的测试。我有 test
文件夹的默认结构。这是相关部分:
test
unit
job_test.rb
test_helper.rb
当我运行时:
ruby unit/job_test.rb
从 test
目录中,我得到:
<internal:lib/rubygems/custom_require>:29:in `require':
no such file to load -- test_helper (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from unit/job_test.rb:1:in `<main>'
这是我的job_test.rb
:
require 'test_helper'
class JobTest < ActiveSupport::TestCase
test "My First Test" do
assert false
end
end
这是一个已知的 Rails 3 问题吗?
有什么解决方法吗?
最佳答案
尝试包含这样的测试助手
require File.dirname(__FILE__) + '/../test_helper'
关于ruby-on-rails - rails 3 : Error when running a simple test using RailsGuides instructions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5255501/