Anu*_*uja 3 ruby-on-rails minitest
如果我运行测试用例:
ruby test/models/chat_bot/option_test.rb
我得到错误:
/home/anuja/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- test_helper (LoadError)
如果我按以下方式运行测试,它将起作用:
rake test test/models/chat_bot/option_test.rb
您需要将您的测试目录添加到 Ruby 的加载路径。否则 Ruby 不知道去哪里找test_helper. 要添加到加载路径,请使用以下-I选项:
ruby -Itest test/models/chat_bot/option_test.rb
它通过添加绝对路径来固定:
require './test/test_helper'
代替:
require 'test_helper'
无论我们在哪里要求相同。然后我可以不带任何参数运行测试用例:
ruby test/models/xyz/option_test.rb