Reputation: 193
I get the following error when trying to run a minitest unit test with ruby test/test_foo.rb
:
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
/home/emile/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/minitest/autorun.rb:15:```
test_foo.rb looks like this:
require 'minitest/autorun'
class TestFoo < MiniTest::Test
#stuf
end
My Gemfile does contain gem 'minitest'
and test_foo.rb does contain require 'minitest/autorun'
, yet I still get the warning.
Is this a bug? Any ideas?
Upvotes: 5
Views: 2484
Reputation: 11957
Run your test using bundle exec ruby test/test_foo.rb
to make sure you use your bundled gems (in this case minitest).
Just running ruby test/test_foo.rb
will use your globally installed Rubygems.
If you want to dig around a little more, try looking in /home/emile/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/minitest/autorun.rb
, around line 15.
Upvotes: 7
Reputation: 8984
▲
I've interepreted the warning literally and added the line gem 'minitest' before the line require 'minitest/autorun', and that seems to work. Odd, or is this expected?
This is expected. It tells ruby to use the gem version and not the standard library version.
Upvotes: 4