Skip to content

Commit

Permalink
Add test (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Oct 31, 2024
1 parent 6161657 commit 34356a2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/ruby_lsp_rails/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,28 @@ def resolve_route_info(requirements)
assert_equal("Hello\n", stderr)
end

test "reloads if routes files change" do
@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
RUBY

@server.execute("reload_routes", {})

@server.execute("route_location", { name: "user_path" })

location = response[:result][:location]
assert_nil(location)
ensure
File.write("test/dummy/config/routes.rb", old_routes)
end

private

def response
Expand Down

0 comments on commit 34356a2

Please sign in to comment.