qrush / m

A Test::Unit runner that can run tests by line number.
MIT License
376 stars 57 forks source link

`No tests found` for line with `describe` #78

Closed AlexWayfer closed 4 years ago

AlexWayfer commented 5 years ago

File

require_relative "spec_helper"

describe "Dataset#any?" do
  it "should return true if records exist in the dataset" do
    db = Sequel.mock(fetch: proc { |sql| { 1 => 1 } unless sql =~ /WHERE 'f'/ })
    db.from(:test).must_be :any?
    db.sqls.must_equal ['SELECT 1 AS one FROM test LIMIT 1']
    db.from(:test).filter(false).wont_be :any?
    db.sqls.must_equal ["SELECT 1 AS one FROM test WHERE 'f' LIMIT 1"]
  end

  it "should ignore order" do
    db = Sequel.mock(fetch: proc { |sql| { 1 => 1 } })
    db.from(:test).must_be :any?
    without_order = db.sqls
    db.from(:test).order(:the_order_column).must_be :any?
    with_order = db.sqls
    without_order.must_equal with_order
  end
end

Command

m file.rb:3

Actual behavior

No tests found on line 3. Valid tests to run:

test_0001_should return true if records exist in the dataset: m file.rb:4
                               test_0002_should ignore order: m file.rb:12

Expected behavior

Run tests inside describe.

zamith commented 4 years ago

Thanks for the issue, however it's unlikely that m will support this unless Minitest also supports a way to access the describe blocks. Currently the describe stack that holds this information is popped as soon as it is evaluated, so it is opaque.

Alternatively, m could parse the files and try to get the context that way, but this is something that we're not doing right now for the tests (we're getting the info from the runners) and don't plan on doing.

The best solution right now to run multiple tests is via m file.rb:4:12.