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 all commits
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
15 changes: 10 additions & 5 deletions test/ruby_lsp_rails/code_lens_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
module RubyLsp
module Rails
class CodeLensTest < ActiveSupport::TestCase
setup do
@message_queue = Thread::Queue.new
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

def teardown
T.must(@message_queue).close
assert_empty(response)
end

test "recognizes Rails Active Support test cases" do
Expand Down
8 changes: 0 additions & 8 deletions test/ruby_lsp_rails/definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
module RubyLsp
module Rails
class DefinitionTest < ActiveSupport::TestCase
setup do
@message_queue = Thread::Queue.new
end

def teardown
T.must(@message_queue).close
end

test "recognizes model callback with multiple symbol arguments" do
response = generate_definitions_for_source(<<~RUBY, { line: 3, character: 10 })
# typed: false
Expand Down
8 changes: 0 additions & 8 deletions test/ruby_lsp_rails/document_symbol_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
module RubyLsp
module Rails
class DocumentSymbolTest < ActiveSupport::TestCase
setup do
@message_queue = Thread::Queue.new
end

def teardown
T.must(@message_queue).close
end

test "recognizes Rails Active Support test cases" do
response = generate_document_symbols_for_source(<<~RUBY)
class Test < ActiveSupport::TestCase
Expand Down
6 changes: 0 additions & 6 deletions test/ruby_lsp_rails/hover_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ module RubyLsp
module Rails
class HoverTest < ActiveSupport::TestCase
setup do
@message_queue = Thread::Queue.new

# Build the Rails documents index ahead of time
capture_io do
Support::RailsDocumentClient.send(:search_index)
end
end

teardown do
@message_queue.close
end

test "hook returns model column information" do
expected_response = {
schema_file: "#{dummy_root}/db/schema.rb",
Expand Down
Loading