Skip to content

Commit 38419ea

Browse files
committed
Convert test suite from Minitest::Spec DSL to Minitest::Test
1 parent 4067339 commit 38419ea

61 files changed

Lines changed: 12742 additions & 12839 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rubocop.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ Lint/MissingSuper:
1919
AllowedParentClasses:
2020
- BasicObject
2121
- Feature
22+
23+
Minitest/MultipleAssertions:
24+
Exclude:
25+
- 'test/**/*.rb'
26+
27+
Minitest/TestFileName:
28+
Exclude:
29+
- 'test/regression_tests.rb'
30+
31+
Naming/VariableNumber:
32+
Exclude:
33+
- 'test/**/*.rb'

.rubocop/metrics.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metrics/AbcSize:
22
Exclude:
3-
- 'test/support/**/*.rb'
3+
- 'test/**/*.rb'
44

55
Metrics/ParameterLists:
66
CountKeywordArgs: false
@@ -20,20 +20,20 @@ Metrics/ClassLength:
2020
- heredoc
2121
- method_call
2222
Exclude:
23-
- 'test/support/**/*.rb'
23+
- 'test/**/*.rb'
2424

2525
Metrics/MethodLength:
2626
CountAsOne:
2727
- array
2828
- heredoc
2929
- method_call
3030
Exclude:
31-
- 'test/support/**/*.rb'
31+
- 'test/**/*.rb'
3232

3333
Metrics/ModuleLength:
3434
CountAsOne:
3535
- array
3636
- heredoc
3737
- method_call
3838
Exclude:
39-
- 'test/support/**/*.rb'
39+
- 'test/**/*.rb'

.rubocop/style.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Style/OneClassPerFile:
1414
Exclude:
1515
- 'test/**/*.rb'
1616

17+
Style/RescueModifier:
18+
Exclude:
19+
- 'test/support/dummy_server.rb'
20+
- 'test/support/proxy_server.rb'
21+
1722
Style/RescueStandardError:
1823
Enabled: true
1924
EnforcedStyle: implicit

lib/http/features/digest_auth.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ def build_auth(request, challenge)
123123
ha1 = compute_ha1(algorithm, challenge.fetch("realm"), nonce, cnonce)
124124
ha2 = compute_ha2(algorithm, String(request.verb).upcase, uri)
125125

126-
compute_auth_header(algorithm, qop, nonce, cnonce, nonce_count, uri, ha1, ha2, challenge)
126+
compute_auth_header(algorithm: algorithm, qop: qop, nonce: nonce, cnonce: cnonce,
127+
nonce_count: nonce_count, uri: uri, ha1: ha1, ha2: ha2,
128+
challenge: challenge)
127129
end
128130

129131
# Compute digest and build the Authorization header string
130132
#
131133
# @return [String] formatted authorization header
132134
# @api private
133-
def compute_auth_header(algorithm, qop, nonce, cnonce, nonce_count, uri, ha1, ha2, challenge) # rubocop:disable Metrics/ParameterLists
135+
def compute_auth_header(algorithm:, qop:, nonce:, cnonce:, nonce_count:, uri:, ha1:, ha2:, challenge:)
134136
response = compute_response(algorithm, ha1, ha2, nonce: nonce,
135137
nonce_count: nonce_count, cnonce: cnonce, qop: qop)
136138

lib/http/headers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def add(name, value)
143143
# @api public
144144
def get(name)
145145
name = normalize_header name
146-
@pile.select { |k, _| k.eql?(name) }.map { |_, _, v| v }
146+
@pile.filter_map { |k, _, v| v if k.eql?(name) }
147147
end
148148

149149
# Smart version of {#get}

sig/http.rbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ module HTTP
563563
def authorize: (Request request, Response response) -> Request
564564
def parse_challenge: (String header) -> Hash[String, String]
565565
def build_auth: (Request request, Hash[String, String] challenge) -> String
566-
def compute_auth_header: (String algorithm, String? qop, String nonce, String cnonce, String nonce_count, String uri, String ha1, String ha2, Hash[String, String] challenge) -> String
566+
def compute_auth_header: (algorithm: String, qop: String?, nonce: String, cnonce: String, nonce_count: String, uri: String, ha1: String, ha2: String, challenge: Hash[String, String]) -> String
567567
def select_qop: (String? qop_str) -> String?
568568
def compute_ha1: (String algorithm, String realm, String nonce, String cnonce) -> String
569569
def compute_ha2: (String algorithm, String method, String uri) -> String
@@ -1014,6 +1014,7 @@ module HTTP
10141014
def redirect?: () -> bool
10151015
def client_error?: () -> bool
10161016
def server_error?: () -> bool
1017+
def not_modified?: () -> bool
10171018
def to_sym: () -> Symbol?
10181019
def inspect: () -> String
10191020
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, Integer | String?]

test/http/base64_test.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
require "test_helper"
44

5-
describe HTTP::Base64 do
5+
class HTTPBase64Test < Minitest::Test
66
cover "HTTP::Base64*"
77

8-
let(:encoder) do
9-
klass = Class.new { include HTTP::Base64 }
10-
klass.new
8+
def encoder
9+
@encoder ||= begin
10+
klass = Class.new { include HTTP::Base64 }
11+
klass.new
12+
end
1113
end
1214

13-
describe "#encode64" do
14-
it "encodes a string using strict Base64 (no newlines)" do
15-
assert_equal "aGVsbG8=", encoder.send(:encode64, "hello")
16-
end
15+
def test_encode64_encodes_a_string_using_strict_base64
16+
assert_equal "aGVsbG8=", encoder.send(:encode64, "hello")
17+
end
1718

18-
it "produces output that round-trips back to the original input" do
19-
input = "user:password"
19+
def test_encode64_produces_output_that_round_trips_back_to_the_original_input
20+
input = "user:password"
2021

21-
assert_equal input, encoder.send(:encode64, input).unpack1("m0")
22-
end
22+
assert_equal input, encoder.send(:encode64, input).unpack1("m0")
23+
end
2324

24-
it "encodes empty string" do
25-
assert_equal "", encoder.send(:encode64, "")
26-
end
25+
def test_encode64_encodes_empty_string
26+
assert_equal "", encoder.send(:encode64, "")
2727
end
2828
end

0 commit comments

Comments
 (0)