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?
Setting Up Minitest. To run a Minitest test, the only setup you really need is to require the autorun file at the beginning of a test file: require 'minitest/autorun' . This is good if you'd like to keep the code small. A better way to get started with Minitest is to have Bundler create a template project for you.
What is Minitest? Minitest is a testing suite for Ruby. It provides a complete suite of testing facilities supporting test-driven development (TDD), behavior-driven development (BDD), mocking, and benchmarking. It's small, fast, and it aims to make tests clean and readable.
Minitest is a testing tool for Ruby that provides a complete suite of testing facilities. It also supports behaviour-driven development, mocking and benchmarking. With the release of Ruby 1.9, it was added to Ruby's standard library, which increased its popularity.
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.
▲
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.
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