minitest / minitest-focus

72 stars 9 forks source link

Breaks when creating rake test task instead of using the default rails test task #7

Closed allavena closed 9 years ago

allavena commented 9 years ago

Hello,

I really enjoy minitest-focus, and cannot live without it, except it does not want to run for me: if you create the rake test task by hand, as opposed to using the default one provided by rails, focus breaks. A task such as the one below will work fine without focus, however, as soon as you add a 'focus' in front of some test, you get a /home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `require': cannot load such file -- /^(My\ tersts#test_0001_should\ do\ nothing\ more)$ (LoadError)

Note that using the Rails.application.load_tasks, then focus actually works and only one test is run. Comment out 'focus' and the test suite runs fine. In case it matters, I'm using the 'spec' notation: describe 'My tersts' do ....

namespace :test do
  desc('Run my tests ')
  Rake::TestTask.new('test') do |t|
    t.pattern = 'test/**/*_test.rb'
    t.libs << 'test'
    t.verbose = true
  end
end
home/andre/.rvm/rubies/ruby-2.1.2/bin/ruby -I"lib:test" -I"/home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib" "/home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" 
/home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `require': cannot load such file -- /^(My\ tersts\#test_0001_should\ do\ nothing\ more)$ (LoadError)
    from /home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `block in <main>'
    from /home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib" "/home/andre/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" ]
zenspider commented 9 years ago

I really should ship with my own rake thingy. The default one is quite awful.

allavena commented 9 years ago

Any chance you can provide in the comments / doc a rake file that works? That would be very appreciated, I haven't managed to reverse engineer the one from rails.

zenspider commented 9 years ago

This is fixed. Should ship soon.

zenspider commented 9 years ago

I don't understand your question. You can use minitest-sprint to run your tests and bypass rake. You can also look at my test task in the hoe gem.