olimorris / neotest-rspec

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

[Bug]: Can't run the rspec command in the correct directory in a monorepo #60

Closed davidmh closed 7 months ago

davidmh commented 9 months ago

RSpec test

No response

Error messages

No lua errors, the error comes from running the rspec in the wrong directory.

Describe the bug

When running the tests in a monorepo, the rspec command will always run from the current working directory, instead of the one holding the Gemfile closest to the spec.

Reproduce the bug

Failure

  1. git clone https://github.com/davidmh/neotest-rspec-monorepo-example
  2. cd neotest-rspec-monorepo-example
  3. nvim -u minimal-init.lua service-a/spec/minimal_spec.rb
  4. :Neotest run<cr>

Success

  1. cd service-a/
  2. nvim -u ../minimal-init.la spec/minimal_spec.rb 3 :Neotest run<cr>

Final checks

olimorris commented 9 months ago

Hey @davidmh and thanks for raising! Yep that is something the plugin can't do. I'll see what other neotest adapters have done to solve this

davidmh commented 9 months ago

I just tried with the python adapter and it seems to have the same issue, so maybe this should be upstreamed into neotest?

olimorris commented 9 months ago

We define a NeotestAdapter.root method in the adapter which detects the folder containing a Gemfile or .rspec file so we may be able to utilise that.