diff --git a/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb b/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb index 5c52b7b5..642eeb25 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb @@ -170,7 +170,7 @@ def make_request(request, params = nil) read_response end - sig { params(request: String, params: T.nilable(T::Hash[Symbol, T.untyped])).void } + sig { overridable.params(request: String, params: T.nilable(T::Hash[Symbol, T.untyped])).void } def send_message(request, params = nil) message = { method: request } message[:params] = params if params @@ -181,9 +181,11 @@ def send_message(request, params = nil) # The server connection died end - alias_method :send_notification, :send_message + # Notifications are like messages, but one-way, with no response sent back. + sig { params(request: String, params: T.nilable(T::Hash[Symbol, T.untyped])).void } + def send_notification(request, params = nil) = send_message(request, params) - sig { returns(T.nilable(T::Hash[Symbol, T.untyped])) } + sig { overridable.returns(T.nilable(T::Hash[Symbol, T.untyped])) } def read_response headers = @stdout.gets("\r\n\r\n") raise IncompleteMessageError unless headers diff --git a/test/ruby_lsp_rails/runner_client_test.rb b/test/ruby_lsp_rails/runner_client_test.rb index 3fd910b6..9ffdf5cb 100644 --- a/test/ruby_lsp_rails/runner_client_test.rb +++ b/test/ruby_lsp_rails/runner_client_test.rb @@ -87,5 +87,33 @@ class RunnerClientTest < ActiveSupport::TestCase FileUtils.mv("test/dummy/config/application.rb.bak", "test/dummy/config/application.rb") end end + + class NullClientTest < ActiveSupport::TestCase + setup { @client = NullClient.new } + + test "#shutdown is a no-op" do + assert_nothing_raised { @client.shutdown } + end + + test "#stopped? is always true" do + assert_predicate @client, :stopped? + end + + test "#rails_root is just the current working directory" do + assert_equal Dir.pwd, @client.rails_root + end + + test "#send_message is a no-op" do + assert_nothing_raised { @client.send(:send_message, "request", nil) } + end + + test "#send_notification is a no-op" do + assert_nothing_raised { @client.send(:send_notification, "request", nil) } + end + + test "#read_response is a no-op" do + assert_nothing_raised { @client.send(:read_response) } + end + end end end