olimorris / neotest-rspec

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

No tests found. #26

Closed prdanelli closed 2 years ago

prdanelli commented 2 years ago

Hello, I'm seeing a No Tests Found message for the following spec:

# frozen_string_literal: true

require "rails_helper"

RSpec.describe Collections::Foodiverse::WaitlistCollectionAdvertiserService do
  describe "Constants" do
    it { expect(described_class.const_defined?(:BODY_MESSAGE_KEY)).to be true }
  end
end

Running rspec via the terminal results in:

Finished in 0.37423 seconds (files took 7.58 seconds to load)
1 example, 0 failures

Randomized with seed 556

Do you know if there is support for the short it syntax?

I'm using Neovim nightly and the latest version of the plugin.

Thank you again for the time you've put in to developing this plugin, I use it pretty much every day.

prdanelli commented 2 years ago

Interestingly, I also get no tests found when i use a normal it message block syntax:

RSpec.describe Collections::Foodiverse::WaitlistCollectionAdvertiserService do
  describe "Constants" do
    it "is there" do
      expect(described_class.const_defined?(:BODY_MESSAGE_KEY)).to be true
    end
  end
end
image
olimorris commented 2 years ago

That's very weird. I've copied the code from your initial post and detected the test.

Obvious question, is there a Gemfile, .rspec or .gitignore file present and are the tests ending in _spec.rb?

Finally if you open /Users/{YourName}/.local/state/nvim/neotest.log and try and run Neotest, you should see some output. Could you share that?

patrickshobe commented 2 years ago

I also have this issue but don't have the log file you specified:

$ cat /Users/$(whoami)/.local/state/nvim/neotest.log                                           │~
cat: /Users/pat/.local/state/nvim/neotest.log: No such file or directory  
olimorris commented 2 years ago

Could you check the share dir? Wonder if I made a mistake and autocorrected to state. I'm not at a laptop at the moment.

Also, any chance you guys could share a repo that displays this bug that I can clone and test with?

olimorris commented 2 years ago

I've pushed a fix. I think the nested describe statements were scuppering this. However I've almost certainly broken #21 and specs which have no context

natematykiewicz commented 2 years ago

I also have this problem. I'm running the commit you pushed a half hour ago.

require 'rails_helper'

RSpec.describe User, type: :model do
  it 'works' do
    expect(1).to be_a(Numeric)
  end
end

Then run:

:lua require('neotest').run.run()

No tests found

olimorris commented 2 years ago

I just can't recreate these No tests found unfortunately. If I plug your code into the playground with the treesitter queries I get the expected outcome:

Screen Shot 2022-09-12 at 22 14 07@2x

@natematykiewicz - Can you share any more details about the repo or the test itself? Can you enable debugging in Neotest and share the outputs of /Users/Oli/.local/state/nvim/neotest.log?

natematykiewicz commented 2 years ago

I somehow didn't have the ruby treesitter installed even though I did the other day. TSInstall ruby fixed my problem. Sorry to bother you.

natematykiewicz commented 2 years ago

Is there a way for it to realize you don't have the Ruby TreeSitter installed and suggest to you the right command to run to install it? Because that'd be an awesome UX.

olimorris commented 2 years ago

Is there a way for it to realize you don't have the Ruby TreeSitter installed and suggest to you the right command to run to install it? Because that'd be an awesome UX.

I'm sure there is but I imagine it would be messy to check if it's installed depending on the user OS etc. I should add an issue template which asks the user to run checkhealth instead.

@prdanelli - Any luck at trying the latest commit?

prdanelli commented 2 years ago

I think the issues I was having might have been around naming the file "test.rb" the renaming it "test_spec.rb" and trying to run the tests before reopening the file. I've tested that scenario and it works perfectly now.

olimorris commented 2 years ago

Appreciate the feedback thanks. I will update the readme at some point to save others some time

exosyphon commented 1 year ago

I somehow didn't have the ruby treesitter installed even though I did the other day. TSInstall ruby fixed my problem. Sorry to bother you.

This resolved my issue as well even though I had it listed in my 'ensure_installed' section.

Drew-Daniels commented 6 months ago

@prdanelli 's suggestion fixed my issue. This seems like something that'd be good to mention in the README somewhere. Granted not many people probably have spec files that don't end in _spec.rb, but still

olimorris commented 6 months ago

Thanks for the prompt. I've updated the readme to reflect this.