Using Minitest, require 'minitest_helper' load error
minitest, ruby, ruby-on-rails
Solution
Your tests aren't finding the helper file because you haven't told your tests to look where it is. try changing your rake task to this:
Rake::TestTask.new do |t|
t.libs << "lib"
t.libs << "spec"
t.test_files = FileList['spec/**/*_spec.rb']
t.verbose = true
end
task :default => :test
Problem
I'm testing out Minitest::Spec as an alternative to RSpec, but I've got a pesky problem I can't quite spot the answer to: I've setup some basic specs in `spec/models/*_spec.rb`. My rails app includes `minitest-rails`, and I've set my rakefile as follows: ``` Rake::TestTask.new do |t| t.libs.push "lib" t.test_files = FileList['spec/**/*_spec.rb'] t.verbose = true end task :default => :test ``` Now, if I write my spec files like this: ``` require 'minitest_helper' describe User do ... end ``` ... and run `rake test`, I get: ``` user_spec.rb:1:in `require': cannot load such file -- minitest_helper (LoadError) ``` however, if I change the require line to ``` require_relative '../minitest_helper' ``` Then it works. So, this is functional, but it seems that every example of people using minitest specs I find online has them just calling `require 'minitest_helper'`, not `require_relative`. So, what am I missing that lets that work for others but not in my situation? One last piece of info, my helper file looks like this: ``` # spec/minitest_helper.rb ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require "minitest/autorun" require "minitest/rails" # Uncomment if you want Capybara in accceptance/integration tests # require "minitest/rails/capybara" # Uncomment if you want awesome colorful output # require "minitest/pride" class MiniTest::Rails::ActiveSupport::TestCase # Add more helper methods to be used by all tests here... end ``` Nothing fancy. Thanks for the help!