I am having a problem running my tests from the terminal and from rake, eg rake test:integration
At the moment, I have the requires for test_helper.rb specified like this:
require File.dirname(__FILE__) + '/../test_helper'
This works fine when running them from the terminal but obviously when it is ran from rake, the directory is different and the process cannot find the test_helper file.
I think I want to add to this to my $load_path but I am not sure how to add it when running only in the test environment.
Can anyone help me out?
You can revert to just require 'test_helper'
(the default for integration tests, at least with Rails 2.3.x). This will allow tests to run from a rake task, and as long as you cd
to the test
directory within your rails app, you can run tests via the terminal with ruby integration/your_test.rb
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.