Skip to content

Commit 4e50add

Browse files
authored
Merge pull request #318 from Shopify/display-code-lens-conditionally
Only display code lens when the test framework is rails
2 parents 1e83430 + c5b2f8e commit 4e50add

File tree

5 files changed

+12
-27
lines changed

5 files changed

+12
-27
lines changed

lib/ruby_lsp/ruby_lsp_rails/addon.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def deactivate
4747
).void
4848
end
4949
def create_code_lens_listener(response_builder, uri, dispatcher)
50+
return unless T.must(@global_state).test_library == "rails"
51+
5052
CodeLens.new(response_builder, uri, dispatcher)
5153
end
5254

test/ruby_lsp_rails/code_lens_test.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
module RubyLsp
77
module Rails
88
class CodeLensTest < ActiveSupport::TestCase
9-
setup do
10-
@message_queue = Thread::Queue.new
11-
end
9+
test "does not create code lenses if rails is not the test library" do
10+
RubyLsp::GlobalState.any_instance.stubs(:test_library).returns("rspec")
11+
response = generate_code_lens_for_source(<<~RUBY)
12+
RSpec.describe "an example" do
13+
it "an example" do
14+
# test body
15+
end
16+
end
17+
RUBY
1218

13-
def teardown
14-
T.must(@message_queue).close
19+
assert_empty(response)
1520
end
1621

1722
test "recognizes Rails Active Support test cases" do

test/ruby_lsp_rails/definition_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
module RubyLsp
77
module Rails
88
class DefinitionTest < ActiveSupport::TestCase
9-
setup do
10-
@message_queue = Thread::Queue.new
11-
end
12-
13-
def teardown
14-
T.must(@message_queue).close
15-
end
16-
179
test "recognizes model callback with multiple symbol arguments" do
1810
response = generate_definitions_for_source(<<~RUBY, { line: 3, character: 10 })
1911
# typed: false

test/ruby_lsp_rails/document_symbol_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
module RubyLsp
77
module Rails
88
class DocumentSymbolTest < ActiveSupport::TestCase
9-
setup do
10-
@message_queue = Thread::Queue.new
11-
end
12-
13-
def teardown
14-
T.must(@message_queue).close
15-
end
16-
179
test "recognizes Rails Active Support test cases" do
1810
response = generate_document_symbols_for_source(<<~RUBY)
1911
class Test < ActiveSupport::TestCase

test/ruby_lsp_rails/hover_test.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,12 @@ module RubyLsp
77
module Rails
88
class HoverTest < ActiveSupport::TestCase
99
setup do
10-
@message_queue = Thread::Queue.new
11-
1210
# Build the Rails documents index ahead of time
1311
capture_io do
1412
Support::RailsDocumentClient.send(:search_index)
1513
end
1614
end
1715

18-
teardown do
19-
@message_queue.close
20-
end
21-
2216
test "hook returns model column information" do
2317
expected_response = {
2418
schema_file: "#{dummy_root}/db/schema.rb",

0 commit comments

Comments
 (0)