Skip to content

Commit

Permalink
Use test helpers from Ruby LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Dec 20, 2024
1 parent 44f8c29 commit f4061df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 38 deletions.
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ gem "tapioca", "~> 0.13", require: false, platforms: :ruby
gem "psych", "~> 5.1", require: false
gem "rails", "8.0.0"

platforms :mingw, :x64_mingw, :mswin, :jruby do
# platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo"
gem "tzinfo-data"
end
# end

# Until https://github.com/Shopify/ruby-lsp/pull/2991 is released
gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "main"
19 changes: 13 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
GIT
remote: https://github.com/Shopify/ruby-lsp.git
revision: 934729fcf05baf6e6074ef85b9be2784dc1b6f17
branch: main
specs:
ruby-lsp (0.23.0)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)

PATH
remote: .
specs:
ruby-lsp-rails (0.3.27)
ruby-lsp (>= 0.22.0, < 0.23.0)
ruby-lsp (>= 0.23.0, < 0.24.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -214,11 +225,6 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.7)
rubocop (>= 1)
ruby-lsp (0.22.0)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.3.1)
Expand Down Expand Up @@ -283,6 +289,7 @@ DEPENDENCIES
rubocop-rake (~> 0.6.0)
rubocop-shopify (~> 2.15)
rubocop-sorbet (~> 0.8)
ruby-lsp!
ruby-lsp-rails!
sorbet-static-and-runtime
sqlite3
Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
Dir["lib/**/*", "LICENSE.txt", "Rakefile", "README.md"]
end

spec.add_dependency("ruby-lsp", ">= 0.22.0", "< 0.23.0")
spec.add_dependency("ruby-lsp", ">= 0.23.0", "< 0.24.0")
end
29 changes: 0 additions & 29 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,5 @@ class TestCase
def dummy_root
File.expand_path("#{__dir__}/dummy")
end

sig { params(server: RubyLsp::Server).returns(RubyLsp::Result) }
def pop_result(server)
result = server.pop_response
result = server.pop_response until result.is_a?(RubyLsp::Result) || result.is_a?(RubyLsp::Error)

refute_instance_of(
RubyLsp::Error,
result,
-> { "Failed to execute request #{T.cast(result, RubyLsp::Error).message}" },
)
T.cast(result, RubyLsp::Result)
end

def pop_log_notification(message_queue, type)
log = message_queue.pop
return log if log.params.type == type

log = message_queue.pop until log.params.type == type
log
end

def pop_message(outgoing_queue, &block)
message = outgoing_queue.pop
return message if block.call(message)

message = outgoing_queue.pop until block.call(message)
message
end
end
end

0 comments on commit f4061df

Please sign in to comment.