Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

nolantait
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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 olimorris merged commit 1b6a43a into olimorris:main Mar 19, 2024
@olimorris
Copy link
Owner

Thank you and sorry for the delay in merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants