This works perfectly when I open neovim in the directory containing the Gemfile. However, this doesn't work when I'm working on a project with multiple roots:
If I'm editing a_spec.rb, I'd want to execute bundle exec spec/a_spec.rb with { cwd = "a" }.
I propose the introduction of runner:find_working_directory(filename) to dynamically infer the working directory. In the case of RSpec, that implementation might look something like this (adapted from here):
function rspec:find_working_directory(filename)
local gemfile = vim.fn.findfile("Gemfile", vim.fn.fnamemodify(filename, ":p") .. ";")
return vim.fn.fnamemodify(gemfile, ":p:h:t")
end
I've configured Rspec like this (which should probably be the default):
This works perfectly when I open neovim in the directory containing the
Gemfile
. However, this doesn't work when I'm working on a project with multiple roots:If I'm editing
a_spec.rb
, I'd want to executebundle exec spec/a_spec.rb
with{ cwd = "a" }
.I propose the introduction of
runner:find_working_directory(filename)
to dynamically infer the working directory. In the case of RSpec, that implementation might look something like this (adapted from here):