Skip to content

Commit 9600d65

Browse files
committed
Avoid network requests while running tests
1 parent b9edb15 commit 9600d65

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/ruby_lsp_rails/hover_test.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module RubyLsp
77
module Rails
88
class HoverTest < ActiveSupport::TestCase
99
setup do
10+
stub_request(:get, %r{https://api\.rubyonrails\.org/v.*/js/search_index\.js})
11+
.with(
12+
headers: {
13+
"Host" => "api.rubyonrails.org",
14+
"User-Agent" => "Ruby",
15+
},
16+
)
17+
.to_return(status: 200, body: "{}", headers: {})
18+
1019
# Build the Rails documents index ahead of time
1120
capture_io do
1221
Support::RailsDocumentClient.send(:search_index)
@@ -186,17 +195,6 @@ class User < ApplicationRecord
186195
end
187196

188197
test "shows documentation for routes DSLs" do
189-
stub_request(:get, "https://api.rubyonrails.org/v7.1.3.2/js/search_index.js")
190-
.with(
191-
headers: {
192-
"Accept" => "*/*",
193-
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
194-
"Host" => "api.rubyonrails.org",
195-
"User-Agent" => "Ruby",
196-
},
197-
)
198-
.to_return(status: 200, body: "", headers: {})
199-
200198
value = hover_on_source("root 'projects#index'", { line: 0, character: 0 }).contents.value
201199

202200
assert_match(/\[Rails Document: `ActionDispatch::Routing::Mapper::Resources#root`\]/, value)

0 commit comments

Comments
 (0)