Skip to content

Commit e8ba0c0

Browse files
committed
"Use assert_nil if expecting nil. This will fail in minitest 6."
1 parent 9d9a4bd commit e8ba0c0

File tree

69 files changed

+196
-196
lines changed

Some content is hidden

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

69 files changed

+196
-196
lines changed

actionpack/test/controller/integration_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_post
289289
assert_response :success
290290
assert_equal "bar", body
291291

292-
assert_equal nil, headers["Set-Cookie"]
292+
assert_nil headers["Set-Cookie"]
293293
assert_equal({ "foo" => "bar" }, cookies.to_hash)
294294
end
295295
end
@@ -308,7 +308,7 @@ def test_post
308308
assert_response :success
309309
assert_equal "bar", body
310310

311-
assert_equal nil, headers["Set-Cookie"]
311+
assert_nil headers["Set-Cookie"]
312312
assert_equal({ "foo" => "bar" }, cookies.to_hash)
313313
end
314314
end

actionpack/test/controller/new_base/bare_metal_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BareEmptyTest < ActiveSupport::TestCase
5252
controller.set_request!(ActionDispatch::Request.empty)
5353
controller.set_response!(BareController.make_response!(controller.request))
5454
controller.index
55-
assert_equal nil, controller.response_body
55+
assert_nil controller.response_body
5656
end
5757
end
5858

actionpack/test/controller/new_base/render_streaming_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ class StreamingTest < Rack::TestCase
101101
assert_body "Hello world, I'm here!"
102102
assert_status 200
103103
assert_equal "22", headers["Content-Length"]
104-
assert_equal nil, headers["Transfer-Encoding"]
104+
assert_nil headers["Transfer-Encoding"]
105105
end
106106

107107
def assert_streaming!(cache = "no-cache")
108108
assert_status 200
109-
assert_equal nil, headers["Content-Length"]
109+
assert_nil headers["Content-Length"]
110110
assert_equal "chunked", headers["Transfer-Encoding"]
111111
assert_equal cache, headers["Cache-Control"]
112112
end

actionpack/test/controller/parameters/parameters_permit_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def walk_permitted(params)
141141
permitted = params.permit(:a, c: [], b: [])
142142
assert_equal 1, permitted[:a]
143143
assert_equal [1, 2, 3], permitted[:b]
144-
assert_equal nil, permitted[:c]
144+
assert_nil permitted[:c]
145145
end
146146

147147
test "key to empty array: arrays of permitted scalars pass" do
@@ -216,7 +216,7 @@ def walk_permitted(params)
216216
test "fetch with a default value of a hash does not mutate the object" do
217217
params = ActionController::Parameters.new({})
218218
params.fetch :foo, {}
219-
assert_equal nil, params[:foo]
219+
assert_nil params[:foo]
220220
end
221221

222222
test "hashes in array values get wrapped" do
@@ -254,8 +254,8 @@ def walk_permitted(params)
254254
end
255255

256256
test "fetch doesnt raise ParameterMissing exception if there is a default that is nil" do
257-
assert_equal nil, @params.fetch(:foo, nil)
258-
assert_equal nil, @params.fetch(:foo) { nil }
257+
assert_nil @params.fetch(:foo, nil)
258+
assert_nil @params.fetch(:foo) { nil }
259259
end
260260

261261
test "KeyError in fetch block should not be covered up" do

actionpack/test/controller/request/test_request_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_test_request_has_session_options_initialized
88

99
def test_mutating_session_options_does_not_affect_default_options
1010
@request.session_options[:myparam] = 123
11-
assert_equal nil, ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
11+
assert_nil ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
1212
end
1313

1414
def test_content_length_has_bytes_count_value

actionpack/test/dispatch/cookies_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,8 @@ def test_legacy_signed_cookie_is_treated_as_nil_by_signed_cookie_jar_if_tampered
944944
@request.headers["Cookie"] = "user_id=45"
945945
get :get_signed_cookie
946946

947-
assert_equal nil, @controller.send(:cookies).signed[:user_id]
948-
assert_equal nil, @response.cookies["user_id"]
947+
assert_nil @controller.send(:cookies).signed[:user_id]
948+
assert_nil @response.cookies["user_id"]
949949
end
950950

951951
def test_legacy_signed_cookie_is_treated_as_nil_by_encrypted_cookie_jar_if_tampered
@@ -955,8 +955,8 @@ def test_legacy_signed_cookie_is_treated_as_nil_by_encrypted_cookie_jar_if_tampe
955955
@request.headers["Cookie"] = "foo=baz"
956956
get :get_encrypted_cookie
957957

958-
assert_equal nil, @controller.send(:cookies).encrypted[:foo]
959-
assert_equal nil, @response.cookies["foo"]
958+
assert_nil @controller.send(:cookies).encrypted[:foo]
959+
assert_nil @response.cookies["foo"]
960960
end
961961

962962
def test_cookie_with_all_domain_option

actionpack/test/dispatch/request/multipart_params_parsing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def teardown
129129
params = parse_multipart("none")
130130
assert_equal %w(submit-name), params.keys.sort
131131
assert_equal "Larry", params["submit-name"]
132-
assert_equal nil, params["files"]
132+
assert_nil params["files"]
133133
end
134134

135135
test "parses empty upload file" do

actionpack/test/dispatch/request_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ class RequestIP < BaseRequestTest
9494
assert_equal "3.4.5.6", request.remote_ip
9595

9696
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,192.168.0.1"
97-
assert_equal nil, request.remote_ip
97+
assert_nil request.remote_ip
9898

9999
request = stub_request "HTTP_X_FORWARDED_FOR" => "9.9.9.9, 3.4.5.6, 172.31.4.4, 10.0.0.1"
100100
assert_equal "3.4.5.6", request.remote_ip
101101

102102
request = stub_request "HTTP_X_FORWARDED_FOR" => "not_ip_address"
103-
assert_equal nil, request.remote_ip
103+
assert_nil request.remote_ip
104104
end
105105

106106
test "remote ip spoof detection" do
@@ -154,7 +154,7 @@ class RequestIP < BaseRequestTest
154154
assert_equal "fe80:0000:0000:0000:0202:b3ff:fe1e:8329", request.remote_ip
155155

156156
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,::1"
157-
assert_equal nil, request.remote_ip
157+
assert_nil request.remote_ip
158158

159159
request = stub_request "HTTP_X_FORWARDED_FOR" => "2001:0db8:85a3:0000:0000:8a2e:0370:7334, fe80:0000:0000:0000:0202:b3ff:fe1e:8329, ::1, fc00::, fc01::, fdff"
160160
assert_equal "fe80:0000:0000:0000:0202:b3ff:fe1e:8329", request.remote_ip
@@ -163,7 +163,7 @@ class RequestIP < BaseRequestTest
163163
assert_equal "FE00::", request.remote_ip
164164

165165
request = stub_request "HTTP_X_FORWARDED_FOR" => "not_ip_address"
166-
assert_equal nil, request.remote_ip
166+
assert_nil request.remote_ip
167167
end
168168

169169
test "remote ip v6 spoof detection" do
@@ -200,7 +200,7 @@ class RequestIP < BaseRequestTest
200200
assert_equal "3.4.5.6", request.remote_ip
201201

202202
request = stub_request "HTTP_X_FORWARDED_FOR" => "67.205.106.73,unknown"
203-
assert_equal nil, request.remote_ip
203+
assert_nil request.remote_ip
204204

205205
request = stub_request "HTTP_X_FORWARDED_FOR" => "9.9.9.9, 3.4.5.6, 10.0.0.1, 67.205.106.73"
206206
assert_equal "3.4.5.6", request.remote_ip
@@ -222,7 +222,7 @@ class RequestIP < BaseRequestTest
222222
assert_equal "::1", request.remote_ip
223223

224224
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,fe80:0000:0000:0000:0202:b3ff:fe1e:8329"
225-
assert_equal nil, request.remote_ip
225+
assert_nil request.remote_ip
226226

227227
request = stub_request "HTTP_X_FORWARDED_FOR" => "fe80:0000:0000:0000:0202:b3ff:fe1e:8329,2001:0db8:85a3:0000:0000:8a2e:0370:7334"
228228
assert_equal "2001:0db8:85a3:0000:0000:8a2e:0370:7334", request.remote_ip
@@ -345,7 +345,7 @@ class RequestPort < BaseRequestTest
345345

346346
test "optional port" do
347347
request = stub_request "HTTP_HOST" => "www.example.org:80"
348-
assert_equal nil, request.optional_port
348+
assert_nil request.optional_port
349349

350350
request = stub_request "HTTP_HOST" => "www.example.org:8080"
351351
assert_equal 8080, request.optional_port
@@ -537,7 +537,7 @@ class RequestCGI < BaseRequestTest
537537

538538
assert_equal "Basic", request.auth_type
539539
assert_equal 0, request.content_length
540-
assert_equal nil, request.content_mime_type
540+
assert_nil request.content_mime_type
541541
assert_equal "CGI/1.1", request.gateway_interface
542542
assert_equal "*/*", request.accept
543543
assert_equal "UTF-8", request.accept_charset
@@ -957,7 +957,7 @@ class RequestMimeType < BaseRequestTest
957957
end
958958

959959
test "no content type" do
960-
assert_equal nil, stub_request.content_mime_type
960+
assert_nil stub_request.content_mime_type
961961
end
962962

963963
test "content type is XML" do
@@ -978,7 +978,7 @@ class RequestMimeType < BaseRequestTest
978978
"HTTP_X_REQUESTED_WITH" => "XMLHttpRequest"
979979
)
980980

981-
assert_equal nil, request.negotiate_mime([Mime[:xml], Mime[:json]])
981+
assert_nil request.negotiate_mime([Mime[:xml], Mime[:json]])
982982
assert_equal Mime[:html], request.negotiate_mime([Mime[:xml], Mime[:html]])
983983
assert_equal Mime[:html], request.negotiate_mime([Mime[:xml], Mime::ALL])
984984
end
@@ -1192,7 +1192,7 @@ class RequestEtag < BaseRequestTest
11921192
test "doesn't match absent If-None-Match" do
11931193
request = stub_request
11941194

1195-
assert_equal nil, request.if_none_match
1195+
assert_nil request.if_none_match
11961196
assert_equal [], request.if_none_match_etags
11971197

11981198
assert_not request.etag_matches?("foo")

actionpack/test/dispatch/response_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_read_body_during_action
7474
@response.body = "Hello, World!"
7575

7676
# even though there's no explicitly set content-type,
77-
assert_equal nil, @response.content_type
77+
assert_nil @response.content_type
7878

7979
# after the action reads back @response.body,
8080
assert_equal "Hello, World!", @response.body
@@ -112,7 +112,7 @@ def test_setting_content_type_header_impacts_content_type_method
112112

113113
def test_empty_content_type_returns_nil
114114
@response.headers['Content-Type'] = ""
115-
assert_equal nil, @response.content_type
115+
assert_nil @response.content_type
116116
end
117117

118118
test "simple output" do

actionpack/test/dispatch/routing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4189,7 +4189,7 @@ def app; APP end
41894189

41904190
test "parameters are reset between constraint checks" do
41914191
get "/bar"
4192-
assert_equal nil, @request.params[:foo]
4192+
assert_nil @request.params[:foo]
41934193
assert_equal "bar", @request.params[:bar]
41944194
end
41954195
end

0 commit comments

Comments
 (0)