Skip to content

Commit e3b1e4b

Browse files
committed
Use library DSL in RBS tests
Replace custom NetHTTPTestSigHelper/NetHTTPRBSTestCase with the standard RBS::UnitTest library DSL, which validates that manifest.yaml declares all required dependencies.
1 parent 90ab4d1 commit e3b1e4b

File tree

2 files changed

+16
-49
lines changed

2 files changed

+16
-49
lines changed

test_sig/test_helper.rb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,4 @@
1-
require "pathname"
21
require "test/unit"
32
require "rbs"
43
require "rbs/test"
54
require "rbs/unit_test"
6-
7-
module NetHTTPTestSigHelper
8-
extend self
9-
10-
LOCAL_SIG_DIR = Pathname(__dir__).join("..", "sig").expand_path
11-
SUPPORT_LIBRARIES = %w[
12-
cgi
13-
net-protocol
14-
open-uri
15-
openssl
16-
resolv
17-
securerandom
18-
socket
19-
strscan
20-
tempfile
21-
timeout
22-
uri
23-
zlib
24-
].freeze
25-
26-
def env
27-
@env ||= begin
28-
loader = RBS::EnvironmentLoader.new
29-
loader.add(path: LOCAL_SIG_DIR)
30-
SUPPORT_LIBRARIES.each do |library|
31-
loader.add(library: library, version: nil)
32-
end
33-
RBS::Environment.from_loader(loader).resolve_type_names
34-
end
35-
end
36-
end
37-
38-
class NetHTTPRBSTestCase < Test::Unit::TestCase
39-
include RBS::UnitTest::TypeAssertions
40-
41-
def self.env
42-
NetHTTPTestSigHelper.env
43-
end
44-
45-
def self.builder
46-
@builder ||= RBS::DefinitionBuilder.new(env: env)
47-
end
48-
end

test_sig/test_net_http.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def with_server(host)
5555
end
5656
end
5757

58-
class NetSingletonTest < NetHTTPRBSTestCase
58+
class NetSingletonTest < Test::Unit::TestCase
59+
include RBS::UnitTest::TypeAssertions
5960
include WithServer
6061

62+
library "net-http"
6163
testing "singleton(::Net::HTTP)"
6264

6365
def test_get
@@ -125,9 +127,11 @@ def test_start
125127
end
126128
end
127129

128-
class NetInstanceTest < NetHTTPRBSTestCase
130+
class NetInstanceTest < Test::Unit::TestCase
131+
include RBS::UnitTest::TypeAssertions
129132
include WithServer
130133

134+
library "net-http"
131135
testing "::Net::HTTP"
132136

133137
class TestNet < Net::HTTP
@@ -397,9 +401,11 @@ def test_request
397401
end
398402
end
399403

400-
class TestHTTPRequest < NetHTTPRBSTestCase
404+
class TestHTTPRequest < Test::Unit::TestCase
405+
include RBS::UnitTest::TypeAssertions
401406
include WithServer
402407

408+
library "net-http"
403409
testing "::Net::HTTPRequest"
404410

405411
def test_inspect
@@ -544,7 +550,10 @@ def test_iteration_on_headers
544550
end
545551
end
546552

547-
class TestSingletonNetHTTPResponse < NetHTTPRBSTestCase
553+
class TestSingletonNetHTTPResponse < Test::Unit::TestCase
554+
include RBS::UnitTest::TypeAssertions
555+
556+
library "net-http"
548557
testing "singleton(::Net::HTTPResponse)"
549558

550559
def test_body_permitted_?
@@ -553,9 +562,11 @@ def test_body_permitted_?
553562
end
554563
end
555564

556-
class TestInstanceNetHTTPResponse < NetHTTPRBSTestCase
565+
class TestInstanceNetHTTPResponse < Test::Unit::TestCase
566+
include RBS::UnitTest::TypeAssertions
557567
include WithServer
558568

569+
library "net-http"
559570
testing "::Net::HTTPResponse"
560571

561572
class Foo

0 commit comments

Comments
 (0)