olimorris / neotest-rspec

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

Support for Engine specs #34

Closed benlubas closed 1 year ago

benlubas commented 1 year ago

When you launch nvim from the root of a rails project with an engine and then try to run the engine tests things would break.

Now there's some detection and some special parsing to make it work.

olimorris commented 1 year ago

If I run this from the summary window I get the following error:

Screen Shot 2023-01-28 at 12 13 17@2x

Also, the test_engine/spec/basic_spec.rb shows failures:

Screen Shot 2023-01-28 at 12 20 53@2x
benlubas commented 1 year ago

Personally, I don't use the summary window so I'll look into that.

The test in the test_engine folder is failing for me b/c of the require 'spec_helper' line. Removing that fixes it.

This makes sense b/c I didn't define spec_helper in the engine. I get that same error when I run the test from the command line (from the engine folder)

Will add that file to the engine as well.

benlubas commented 1 year ago

still broken..

benlubas commented 1 year ago

The issue with running the entire file (which is the same problem that causes running from the summary window to fail) seems to be an issue with using vim.fn.expand('%') b/c under the hood it calls vimL. Here is the full error in text:

E5560: vimL function must not be called in a lua loop callback

So running vimL is apparently not allowed to happen in a lua loop? But the thing that I don't get is that running a single test works just fine, even running a describe block with a bunch of nested tests works great, just running an entire file breaks for some reason...

Do you know of a way to get the equivalent of vim.fn.expand('%') without calling vimL under the hood?

vim.api.nvim_buf_get_name(0) gets the full file path. So /Users/me/neotest-rspec/test_engine/spec/basic_spec.rb where I just want test_engine/spec/basic_spec.rb. It would also solve the issue if there was an easy way to get the current working directory without vimL, but vim.fn.getcwd() uses vimL as well it seems.

olimorris commented 1 year ago

Do you know of a way to get the equivalent of vim.fn.expand('%') without calling vimL under the hood?

Yeah I've had this error a few times. You could try using the require("neotest.async") library. I believe it's just an async wrapper for vim functions.

Or, you could use require("neotest.async").getcwd() and remove this from vim.api.nvim_buf_get_name(0)

benlubas commented 1 year ago

Oh that's cool. Thanks for the help. This now works with the summary panel for me, and I can run an entire file.

olimorris commented 1 year ago

LGTM!

Thanks for this