weizheheng / ror.nvim

Have FUN builiding Ruby on Rails applications with Neovim!
MIT License
132 stars 15 forks source link

No active terminal buffer to attach to. #3

Closed bugthing closed 2 years ago

bugthing commented 2 years ago

hello, great plugin, thanks for sharing your hard work, looks like a great idea.

I have installed this as per the README and when I run a test the floating window appears saying "Running test" .. but it then disappears and nothing else happens. If I try to attach a terminal is reports "No active terminal buffer to attach to.". I am using neovim v0.7.2

Wondered if you knew what steps I could take to try to locate the cause of my problem?

otavioschwanck commented 2 years ago

Here too:

^I...m/site/pack/packer/start/ror.nvim/lua/ror/test/rspec.lua:32: in function 'get_examples' ^I...m/site/pack/packer/start/ror.nvim/lua/ror/test/rspec.lua:37: in function <...m/site/pack/packer/start/ror.nvim/lua/ror/test/rspec.lua:8>

weizheheng commented 2 years ago

Thanks for the issue, I think this should be fixed once I pushed my local code up. Currently on holiday so my laptop is not with me.

weizheheng commented 2 years ago

Please try with the latest main branch and see if it fixes the problem. Thank you.

bugthing commented 2 years ago

thanks for the update.. behaviour has changed abit but still does not seem to work for me. When I run against a line in the spec file file, it says "Running test on line..." .. waits for a few seconds, then reports the following on the bottom line:

{"version":"3.10.2","messages":["Run options: include {:locations=\u003e{\"./spec/validators/notif...:0,"pending_count":0,"errors_outside_of_examples_count":0},"summary_line":"1 example, 0 failures"}

Is there away to see/change the command being used to execute the test?

weizheheng commented 2 years ago

Currently, there is no way to change the command used to execute the test, but here's the command this plugin is using to run a rspec test:

bundle exec rspec path/to/spec.rb --format j
bundle exec rspec path/to/spec.rb:line_number --format j

Do you mind sharing your spec file and also the output of running the above commands in your console?

weizheheng commented 2 years ago

It seems like it's an empty spec file is it? Cause I don't see any examples in the test result. Are you trying to attach to the terminal running the test? This is useful only when you put a debugger somewhere to debug your test. Otherwise, once the Running test on line ... indicator goes away meaning the test finish running and the terminal will no longer be there for you to attach to.

bugthing commented 2 years ago

the spec file is not empty.. here is an example:

require "rails_helper"

RSpec.describe Organisation, type: :model do
  it { should_not allow_value("123").for(:notification_email ) }

when I run in a terminal, like so

bundle exec rspec spec/models/organisation_spec.rb:4 --format j

is see:

E, [2022-10-11T09:40:51.874589 #14536] ERROR -- : Failed to connect fluentd: getaddrinfo: Name or service not known
E, [2022-10-11T09:40:51.874688 #14536] ERROR -- : Connection will be retried.
{"version":"3.10.2","messages":["Run options: include {:locations=\u003e{\"./spec/models/organisation_spec.rb\"=\u003e[4]}}"],"seed":54145,"examples":[{"id":"./spec/models/organisation_spec.rb[1:1]","description":"is expected not to allow :notification_email to be ‹\"123\"›","full_description":"Organisation is expected not to allow :notification_email to be ‹\"123\"›","status":"passed","file_path":"./spec/models/organisation_spec.rb","line_number":4,"run_time":0.092197735,"pending_message":null}],"summary":{"duration":0.093451714,"example_count":1,"failure_count":0,"pending_count":0,"errors_outside_of_examples_count":0},"summary_line":"1 example, 0 failures"}

so looks ok.. except the STDERR output, perhaps that is causing the problem :shrug:

bugthing commented 2 years ago

OMG!.. it is working!

It has added the tick/cross... I just failed to see it dues to the size of my terminal and was put off by the output at the bottom on the screen.

thanks alot for helping me find my problem, sorry to waste time.

Do you think it would be possible to customise the command used to run specs? .. I use overmind on many projects and run the specs like so: overmind run bundle exec rspec ...

weizheheng commented 2 years ago

Glad that it's working, you can try updating the plugin again, the output shouldn't be there, I forgot to remove it while debugging the other day.

Customizing the command should be possible, but it might be tedious to make sure all the commands are returning the result this plugin is expecting. I am using overmind myself as well, what's the difference with and without overmind run?

bugthing commented 2 years ago

what's the difference with and without overmind run?

I use overmind because its great but also as a common way help manage the enviroment vars across different projects (like an .env file but .overmind.env) .. so when running with overmind run I get a env I want

weizheheng commented 2 years ago

I see, I have been using overmind to run those processes defined in the Procfile.dev, but never use it to run the test.

To answer your question, I am open to PR to allow customizing the test command.