Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit b54f93c

Browse files
committed
Use assert_nil, File.exist?
1 parent 941a829 commit b54f93c

12 files changed

+73
-75
lines changed

test/test_associationmanager.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def setup
304304
# server error or is otherwise undecipherable.
305305
def test_bad_response
306306
assert_log_matches('Server error when requesting an association') {
307-
assert_equal(call_negotiate([mk_message({})]), nil)
307+
assert_nil(call_negotiate([mk_message({})]))
308308
}
309309
end
310310

@@ -320,7 +320,7 @@ def test_empty_assoc_type
320320
"Server #{@server_url} responded with unsupported "\
321321
"association session but did not supply a fallback."
322322
) {
323-
assert_equal(call_negotiate([msg]), nil)
323+
assert_nil(call_negotiate([msg]))
324324
}
325325

326326
end
@@ -337,7 +337,7 @@ def test_empty_session_type
337337
"Server #{@server_url} responded with unsupported "\
338338
"association session but did not supply a fallback."
339339
) {
340-
assert_equal(call_negotiate([msg]), nil)
340+
assert_nil(call_negotiate([msg]))
341341
}
342342
end
343343

@@ -357,7 +357,7 @@ def test_not_allowed
357357

358358
assert_log_matches('Unsupported association type',
359359
'Server sent unsupported session/association type:') {
360-
assert_equal(call_negotiate([msg], negotiator), nil)
360+
assert_nil(call_negotiate([msg], negotiator))
361361
}
362362
end
363363

@@ -388,7 +388,7 @@ def test_unsupported_with_retry_and_fail
388388

389389
assert_log_matches('Unsupported association type',
390390
"Server #{@server_url} refused") {
391-
assert_equal(call_negotiate([msg, msg]), nil)
391+
assert_nil(call_negotiate([msg, msg]))
392392
}
393393
end
394394

@@ -424,7 +424,7 @@ def setup
424424
def test_bad_response
425425
assert_log_matches('Server error when requesting an association') {
426426
response = call_negotiate([mk_message({})])
427-
assert_equal(nil, response)
427+
assert_nil(response)
428428
}
429429
end
430430

@@ -436,7 +436,7 @@ def test_empty_assoc_type
436436

437437
assert_log_matches('Server error when requesting an association') {
438438
response = call_negotiate([msg])
439-
assert_equal(nil, response)
439+
assert_nil(response)
440440
}
441441
end
442442

@@ -448,7 +448,7 @@ def test_empty_session_type
448448

449449
assert_log_matches('Server error when requesting an association') {
450450
response = call_negotiate([msg])
451-
assert_equal(nil, response)
451+
assert_nil(response)
452452
}
453453
end
454454

@@ -466,7 +466,7 @@ def test_not_allowed
466466

467467
assert_log_matches('Server error when requesting an association') {
468468
response = call_negotiate([msg])
469-
assert_equal(nil, response)
469+
assert_nil(response)
470470
}
471471
end
472472

@@ -482,7 +482,7 @@ def test_unsupported_with_retry
482482

483483
assert_log_matches('Server error when requesting an association') {
484484
response = call_negotiate([msg, assoc])
485-
assert_equal(nil, response)
485+
assert_nil(response)
486486
}
487487
end
488488

@@ -818,13 +818,13 @@ def set_negotiate_response(assoc)
818818

819819
def test_not_in_store_no_response
820820
set_negotiate_response(nil)
821-
assert_equal(nil, @assoc_manager.get_association)
821+
assert_nil(@assoc_manager.get_association)
822822
end
823823

824824
def test_not_in_store_negotiate_assoc
825825
# Not stored beforehand:
826826
stored_assoc = @store.get_association(@server_url, @assoc.handle)
827-
assert_equal(nil, stored_assoc)
827+
assert_nil(stored_assoc)
828828

829829
# Returned from associate call:
830830
set_negotiate_response(@assoc)
@@ -898,7 +898,7 @@ def test_success
898898
def test_missing_fields
899899
@message.del_arg(OPENID_NS, 'assoc_type')
900900
assert_log_matches('Missing required par') {
901-
assert_equal(nil, make_request)
901+
assert_nil(make_request)
902902
}
903903
end
904904

@@ -907,7 +907,7 @@ def test_missing_fields
907907
def test_protocol_error
908908
@message.set_arg(OPENID_NS, 'expires_in', 'goats')
909909
assert_log_matches('Protocol error processing') {
910-
assert_equal(nil, make_request)
910+
assert_nil(make_request)
911911
}
912912
end
913913
end

test/test_ax.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_construct
4747
assert_equal(type_uri, ainfo.type_uri)
4848
assert_equal(1, ainfo.count)
4949
assert_equal(false, ainfo.required)
50-
assert_equal(nil, ainfo.ns_alias)
50+
assert_nil(ainfo.ns_alias)
5151
end
5252
end
5353

@@ -234,7 +234,7 @@ def test_mode
234234

235235
def test_construct
236236
assert_equal({}, @msg.requested_attributes)
237-
assert_equal(nil, @msg.update_url)
237+
assert_nil(@msg.update_url)
238238

239239
msg = FetchRequest.new('hailstorm')
240240
assert_equal({}, msg.requested_attributes)
@@ -494,7 +494,7 @@ def setup
494494
end
495495

496496
def test_construct
497-
assert_equal(nil, @msg.update_url)
497+
assert_nil(@msg.update_url)
498498
assert_equal({}, @msg.data)
499499
end
500500

@@ -541,7 +541,7 @@ def test_update_url_in_response
541541
end
542542

543543
def test_get_extension_args_single_value_response
544-
# Single values do NOT have a count, and
544+
# Single values do NOT have a count, and
545545
# do not use the array extension
546546
eargs = {
547547
'mode' => 'fetch_response',
@@ -585,7 +585,7 @@ def test_get_single_success
585585
end
586586

587587
def test_get_single_none
588-
assert_equal(nil, @msg.get_single(@type_a))
588+
assert_nil(@msg.get_single(@type_a))
589589
end
590590

591591
def test_get_single_extra

test/test_consumer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_set_get
1616
assert_equal(:endpoint, ep)
1717
consumer.send(:cleanup_last_requested_endpoint)
1818
ep = consumer.send(:last_requested_endpoint)
19-
assert_equal(nil, ep)
19+
assert_nil(ep)
2020
end
2121
end
2222

test/test_discover.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,16 +724,16 @@ def test_isOPEndpoint
724724
end
725725

726726
def test_noIdentifiers
727-
assert_equal(@endpoint.get_local_id, nil)
728-
assert_equal(@endpoint.claimed_id, nil)
727+
assert_nil(@endpoint.get_local_id)
728+
assert_nil(@endpoint.claimed_id)
729729
end
730730

731731
def test_compatibility
732732
assert(!@endpoint.compatibility_mode())
733733
end
734734

735735
def test_canonical_id
736-
assert_equal(@endpoint.canonical_id, nil)
736+
assert_nil(@endpoint.canonical_id)
737737
end
738738

739739
def test_serverURL

test/test_discovery_manager.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def test_next
2121
assert_equal(@disco_services.next, @services[1])
2222
assert_equal(@disco_services.current, @services[1])
2323

24-
assert_equal(@disco_services.next, nil)
25-
assert_equal(@disco_services.current, nil)
24+
assert_nil(@disco_services.next)
25+
assert_nil(@disco_services.current)
2626
end
2727

2828
def test_for_url
@@ -84,7 +84,7 @@ def test_construct
8484
end
8585

8686
def test_get_next_service
87-
assert_equal(@session[@key], nil)
87+
assert_nil(@session[@key])
8888

8989
next_service = @manager.get_next_service {
9090
[@yadis_url, ["one", "two", "three"]]
@@ -123,24 +123,24 @@ def test_get_next_service
123123
["unused", []]
124124
}
125125

126-
assert_equal(result, nil)
126+
assert_nil(result)
127127
end
128128

129129
def test_cleanup
130130
# With no preexisting manager, cleanup() returns nil.
131-
assert_equal(@manager.cleanup, nil)
131+
assert_nil(@manager.cleanup)
132132

133133
# With a manager, it returns the manager's current service.
134134
disco = Consumer::DiscoveredServices.new(@url, @yadis_url, ["one", "two"])
135135

136136
@session[@key] = disco
137-
assert_equal(@manager.cleanup, nil)
138-
assert_equal(@session[@key], nil)
137+
assert_nil(@manager.cleanup)
138+
assert_nil(@session[@key])
139139

140140
disco.next
141141
@session[@key] = disco
142142
assert_equal(@manager.cleanup, "one")
143-
assert_equal(@session[@key], nil)
143+
assert_nil(@session[@key])
144144

145145
# The force parameter should be passed through to get_manager
146146
# and destroy_manager.
@@ -178,7 +178,7 @@ def test_get_manager
178178
disco2 = Consumer::DiscoveredServices.new("http://not.this.url.com/",
179179
"http://other.yadis.url/", ["one"])
180180
@session[@key] = disco2
181-
assert_equal(@manager.get_manager, nil)
181+
assert_nil(@manager.get_manager)
182182
assert_equal(@manager.get_manager(true), disco2)
183183
end
184184

0 commit comments

Comments
 (0)