Skip to content

Commit

Permalink
Merge pull request #318 from Shopify/display-code-lens-conditionally
Browse files Browse the repository at this point in the history
Only display code lens when the test framework is rails
  • Loading branch information
st0012 authored Apr 3, 2024
2 parents 1e83430 + c5b2f8e commit 4e50add
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
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"

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

0 comments on commit 4e50add

Please sign in to comment.