-
Notifications
You must be signed in to change notification settings - Fork 394
Minitest
It's difficult to run individual tests with Minitest, because it doesn't accept line numbers (like RSpec), it only accepts regexes and test names. Test.vim, however, polyfills this limitation by parsing the file to determine which test is the closest to your cursor, and constructs a regex.
All of the Minitest syntaxes are supported:
-
Classic unit syntax
class MathTest < Minitest::Test def test_addition assert_equal 2, 1 + 1 end end
:TestNearest => ruby -I test math_test.rb --name '/MathTest#test_addition/'
-
Rails' unit syntax
class MathTest < ActiveSupport::TestCase test "addition" do assert_equal 2, 1 + 1 end end
:TestNearest => ruby -I test math_test.rb --name '/MathTest#test_addition/'
-
Classic spec syntax
describe "Math" do it "adds numbers" do (1 + 1).must_equal 2 end end
:TestNearest => ruby -I test math_test.rb --name '/Math#test_\d+_adds numbers/'
-
Explicit spec syntax
class MathTest < Minitest::Spec it "adds numbers" do (1 + 1).must_equal 2 end end
:TestNearest => ruby -I test math_test.rb --name '/MathTest#test_\d+_adds numbers/'
Test.vim's Minitest wrapper chooses the executable using the following logic:
- If you have a Rakefile with a
Rake::TestTask
defined, or you're using Rails, then - if
.zeus.sock
is detected runzeus rake test
, - otherwise if
bin/rake
is present, runbin/rake
, - otherwise if
Gemfile
is present, runbundle exec rake
, - otherwise run
rake
. - If Rakefile is not present, then
- if
Gemfile
is present, runbundle exec ruby -I test
, - otherwise run
ruby -I test
.
Whether or not you're using Rake for running your Minitest suite, Test.vim goes to great lengths to provide the same experience.
When using Rake, it's really difficult to pass test options. Luckily, test.vim has solved that problem for you:
:TestFile --seed 1234
=> rake test TEST="your_file_test.rb" TESTOPTS="--seed=1234"
When not using Rake, it's really difficult to run the whole test suite. Test.vim has got your back here as well:
:TestSuite
=> ruby -I test -e 'Dir["./test/**/*_test.rb"].each &method(:require)'
If you want test.vim to use M for running tests, you can set the executable:
let g:test#ruby#minitest#executable = 'm'