diff --git a/test/ruby_lsp_rails/server_test.rb b/test/ruby_lsp_rails/server_test.rb index e67de8e6..e0f095f3 100644 --- a/test/ruby_lsp_rails/server_test.rb +++ b/test/ruby_lsp_rails/server_test.rb @@ -177,12 +177,12 @@ def resolve_route_info(requirements) end test "reloads if routes files change" do + old_routes = File.read("test/dummy/config/routes.rb") + @server.execute("route_location", { name: "user_path" }) location = response[:result][:location] assert_match(%r{test/dummy/config/routes.rb:5$}, location) - old_routes = File.read("test/dummy/config/routes.rb") - File.write("test/dummy/config/routes.rb", <<~RUBY) Rails.application.routes.draw do end @@ -192,8 +192,7 @@ def resolve_route_info(requirements) @server.execute("route_location", { name: "user_path" }) - location = response[:result][:location] - assert_nil(location) + assert_nil(response[:result]) ensure File.write("test/dummy/config/routes.rb", old_routes) end @@ -201,7 +200,10 @@ def resolve_route_info(requirements) private def response - _headers, content = @stdout.string.split("\r\n\r\n") - JSON.parse(content, symbolize_names: true) + headers, content = @stdout.string.split("\r\n\r\n") + content_length = headers[/Content-Length: (\d+)/i, 1].to_i + binding.break + # @stdout.string = "" + JSON.parse(content.first(content_length), symbolize_names: true) end end