Skip to content

Commit 398b51e

Browse files
committed
Avoid network requests during tests
1 parent fee564a commit 398b51e

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ gem "sorbet-static-and-runtime", platforms: :ruby
1919
gem "tapioca", "~> 0.13", require: false, platforms: :ruby
2020
gem "psych", "~> 5.1", require: false
2121
gem "rails"
22+
gem "webmock"

Gemfile.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ GEM
9090
minitest (>= 5.1)
9191
mutex_m
9292
tzinfo (~> 2.0)
93+
addressable (2.8.6)
94+
public_suffix (>= 2.0.2, < 6.0)
9395
ast (2.4.2)
9496
base64 (0.2.0)
9597
bigdecimal (3.1.6)
9698
builder (3.2.4)
9799
concurrent-ruby (1.2.3)
98100
connection_pool (2.4.1)
101+
crack (1.0.0)
102+
bigdecimal
103+
rexml
99104
crass (1.0.6)
100105
date (3.3.4)
101106
debug (1.9.2)
@@ -106,6 +111,7 @@ GEM
106111
erubi (1.12.0)
107112
globalid (1.2.1)
108113
activesupport (>= 6.1)
114+
hashdiff (1.1.0)
109115
i18n (1.14.1)
110116
concurrent-ruby (~> 1.0)
111117
io-console (0.7.2)
@@ -152,6 +158,7 @@ GEM
152158
prism (0.24.0)
153159
psych (5.1.2)
154160
stringio
161+
public_suffix (5.0.5)
155162
puma (6.4.2)
156163
nio4r (~> 2.0)
157164
racc (1.7.3)
@@ -260,6 +267,10 @@ GEM
260267
tzinfo (2.0.6)
261268
concurrent-ruby (~> 1.0)
262269
unicode-display_width (2.5.0)
270+
webmock (3.23.0)
271+
addressable (>= 2.8.0)
272+
crack (>= 0.3.2)
273+
hashdiff (>= 0.4.0, < 2.0.0)
263274
webrick (1.8.1)
264275
websocket-driver (0.7.6)
265276
websocket-extensions (>= 0.1.0)
@@ -290,6 +301,7 @@ DEPENDENCIES
290301
sorbet-static-and-runtime
291302
sqlite3
292303
tapioca (~> 0.13)
304+
webmock
293305

294306
BUNDLED WITH
295307
2.5.6

test/ruby_lsp_rails/hover_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ class User < ApplicationRecord
186186
end
187187

188188
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+
189200
value = hover_on_source("root 'projects#index'", { line: 0, character: 0 }).contents.value
190201

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

test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
require "ruby_lsp/internal"
1414
require "ruby_lsp/test_helper"
1515
require "ruby_lsp/ruby_lsp_rails/addon"
16+
require "webmock/minitest"
1617

1718
if defined?(DEBUGGER__)
1819
DEBUGGER__::CONFIG[:skip_path] =

0 commit comments

Comments
 (0)