olimorris / neotest-rspec

🧪 Neotest adapter for RSpec. Works in Docker containers too
MIT License
90 stars 26 forks source link

[feat] Pass position_type to allow more rspec_cmd customization #62

Closed nolantait closed 7 months ago

nolantait commented 7 months ago

I have an RSpec test that uses data to generate tests such as:

RSpec.describe SomeClass do
  describe "some feature" do
    FIXTURES.each do |method, path|
      it "does something with the #{method} and #{path}" do
        # ...
      end
    end
  end
end

The problem is that running a typical bundle exec rspec with the runner will show this passing even if some of the generated tests fail. I can fix it by making my command bundle exec rspec --fail-fast however now the entire test file will fail if a single test does.

This PR enables someone to change the rspec command depending on the type of test they ran, which would fix my issue like so:

rspec_cmd = function(position_type)
  if position_type == "test" then
    return vim.tbl_flatten({
      "bundle",
      "exec",
      "rspec",
      "--fail-fast"
    })
  else
    return vim.tbl_flatten({
      "bundle",
      "exec",
      "rspec",
    })
  end
end

As a side note, I ran the test suite when I started but there were already failing specs. I made sure no new specs failed but I didn't fix those specs before implementing. Happy to change this PR with any changes you want.

olimorris commented 7 months ago

Thanks so much for this PR. This is awesome and something I would never run into!

Could I ask that you add something to the README to document this? It's such a great use case.

nolantait commented 7 months ago

Sure thing, I had a small comment in there already but I added some more details about this issue and the reason for position_type. Let me know if that works or you wanted more.

olimorris commented 7 months ago

Thank you and sorry for the delay in merging!