minitest-spec-rails: rails 5 test outputs wrong location of test case

Rails 5 now support testing a single test by specifying a line number on a file (just like rspec). However when using this gem it appears like that functionality is somehow messed up.

When running rails test test/controllers/controller_name_test.rb I expect rails to output the the line number of the failed test in order to focus on a single test.

like this bin/rails test /home/developer/my_rails_app/test/controllers/controller_name_test.rb:81

However the result is actually like this: bin/rails test /home/developer/vendor/ruby/2.3.0/gems/minitest-spec-rails-5.4.0/lib/minitest-spec-rails/dsl.rb:27

I am not sure who is to blame here but since the response from rails is pointing to this gem I suspect this gem is doing something funky to mess up this new capability.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Have the same issue - line number specification stopped working on a vanilla Rails 5 app when the minitest-spec-rails gem is added. However, it’s syntax based. When the gem is added, test 'bar' do; refute true; end stops working (no tests run), but it 'bar' do; refute true; end does work. I’l poke around in the source for a solution and PR, but that might be a contributing factor to what @espen and @andrewferk were seeing. Here’s my fix in test_helper for now:

class ActiveSupport::TestCase

  class << self
    alias :test :it
  end

  ...
 end

(Great gem, BTW!)