I downloaded source code for a project, found a bug, and fixed it.
Now I want to run tests to find out if I have broken anything.
The Tests are in minitest D
$ rake test
ran out of the rails 5.0 box.
Another way to do this using only Ruby's standard library is with Dir.glob. From within a ruby file, this would look like this:
require "minitest/autorun"
Dir.glob("**/*Test.rb") { |f| require_relative(f) }
Or from the commandline, you can use this command:
ruby -I . -e "require 'minitest/autorun'; Dir.glob('**/*Test.rb') { |f| require(f) }"
Dir.glob('**/*Test.rb')
recursively searches the current directory for any file which matches *Test.rb
, so we simply take all those files and require
or require_relative
them. From the commandline, require_relative
fails, so we use require
but first add the current directory to the $LOAD_PATH
through -I .
This can also be done via a Makefile.
default:
echo "Dir.glob('./test/*_test.rb').each { |file| require file}" | ruby
running make
will run all your tests.