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

Only display code lens when the test framework is rails #318

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def deactivate
).void
end
def create_code_lens_listener(response_builder, uri, dispatcher)
return unless T.must(@global_state).test_library == "rails"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to skip the entire listener because it's only used for test code lends atm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably fine for now, but we'll need to re-think for @gmcgibbon's work in #239

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be worth creating a separate listener for that feature now that we have conditions like this.


CodeLens.new(response_builder, uri, dispatcher)
end

Expand Down
13 changes: 13 additions & 0 deletions test/ruby_lsp_rails/code_lens_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ def teardown
T.must(@message_queue).close
end

test "does not create code lenses if rails is not the test library" do
RubyLsp::GlobalState.any_instance.stubs(:test_library).returns("rspec")
response = generate_code_lens_for_source(<<~RUBY)
RSpec.describe "an example" do
it "an example" do
# test body
end
end
RUBY

assert_empty(response)
end

test "recognizes Rails Active Support test cases" do
response = generate_code_lens_for_source(<<~RUBY)
class Test < ActiveSupport::TestCase
Expand Down
Loading