Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Shared examples break when only some of the cases fail #74

Open
4 tasks done
elken opened this issue Oct 22, 2024 · 0 comments
Open
4 tasks done

[Bug]: Shared examples break when only some of the cases fail #74

elken opened this issue Oct 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@elken
Copy link
Contributor

elken commented Oct 22, 2024

RSpec test

RSpec.shared_examples 'to be included' do
  it 'adds two numbers together' do
    expect(subject).to eq(1)
  end
end
require_relative './shared_examples'

RSpec.describe 'Failing Group' do
  subject { 2 }
  it_behaves_like 'to be included'
end

RSpec.describe 'Passing Group' do
  subject { 1 }
  it_behaves_like 'to be included'
end

Error messages

No response

Neotest logs

Nothing logged

Describe the bug

Expected

When running a shared example test in which only 1 result passes as above, I should see 1 pass and 1 fail in the UI/summary/etc.

Actual

image

image

Instead the whole file fails in neovim only. I've inspected the JSON output and there's nothing obvious there, so as you're more of a domain expert I'll have to defer to you 😄

Reproduce the bug

  1. Apply the below diff
diff --git a/spec/included_examples/included_examples_spec.rb b/spec/included_examples/included_examples_spec.rb
index 1d08318..305e84b 100644
--- a/spec/included_examples/included_examples_spec.rb
+++ b/spec/included_examples/included_examples_spec.rb
@@ -1,5 +1,11 @@
-require_relative "./shared_examples"
+require_relative './shared_examples'
 
-RSpec.describe 'Included Examples' do
+RSpec.describe 'Failing Group' do
+  subject { 2 }
+  it_behaves_like 'to be included'
+end
+
+RSpec.describe 'Passing Group' do
+  subject { 1 }
   it_behaves_like 'to be included'
 end
diff --git a/spec/included_examples/shared_examples.rb b/spec/included_examples/shared_examples.rb
index fcb21e8..8671a42 100644
--- a/spec/included_examples/shared_examples.rb
+++ b/spec/included_examples/shared_examples.rb
@@ -1,5 +1,5 @@
 RSpec.shared_examples 'to be included' do
   it 'adds two numbers together' do
-    expect(2+2).to eq(4)
+    expect(subject).to eq(1)
   end
 end
  1. Open nvim
  2. Run the whole file in rspec

Final checks

  • I have made sure this issue exists in the latest version of the plugin
  • I have tested with the minimal.lua config file above and still get the issue
  • I have confirmed that Treesitter is working correctly by running :checkhealth treesitter
  • I have made sure this is not a duplicate issue
@elken elken added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants