Skip to content

Commit

Permalink
Fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Nov 1, 2024
1 parent 95bd0ec commit 30a8a50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/ruby_lsp_rails/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -192,16 +192,18 @@ 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

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

0 comments on commit 30a8a50

Please sign in to comment.