If I run test case:
ruby test/models/chat_bot/option_test.rb
I get error:
/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)
and it works if I run test as follow:
rake test test/models/chat_bot/option_test.rb
You need to add your test directory to Ruby's load path. Otherwise Ruby doesn't know where to look to find test_helper
. To add to the load path, use the -I
option:
ruby -Itest test/models/chat_bot/option_test.rb
It is fixed by adding absolute path:
require './test/test_helper'
instead of:
require 'test_helper'
wherever we require the same. And then I can run test case without any parameter:
ruby test/models/xyz/option_test.rb
Somehow running rails test <test_file_path>
from my project's root solves the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With