Skip to content

Commit d79b3f5

Browse files
committed
Prefer dedicated assertion methods
1 parent 139ebb7 commit d79b3f5

File tree

6 files changed

+58
-58
lines changed

6 files changed

+58
-58
lines changed

test/uri/test_ftp.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ def test_paths
3333
# If you think what's below is wrong, please read RubyForge bug 2055,
3434
# RFC 1738 section 3.2.2, and RFC 2396.
3535
u = URI.parse('ftp://ftp.example.com/foo/bar/file.ext')
36-
assert(u.path == 'foo/bar/file.ext')
36+
assert_equal('foo/bar/file.ext', u.path)
3737
u = URI.parse('ftp://ftp.example.com//foo/bar/file.ext')
38-
assert(u.path == '/foo/bar/file.ext')
38+
assert_equal('/foo/bar/file.ext', u.path)
3939
u = URI.parse('ftp://ftp.example.com/%2Ffoo/bar/file.ext')
40-
assert(u.path == '/foo/bar/file.ext')
40+
assert_equal('/foo/bar/file.ext', u.path)
4141
end
4242

4343
def test_assemble
4444
# uri/ftp is conservative and uses the older RFC 1738 rules, rather than
4545
# assuming everyone else has implemented RFC 2396.
4646
uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
4747
'/path/file.zip', 'i'])
48-
assert(uri.to_s ==
49-
'ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i')
48+
assert_equal('ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i',
49+
uri.to_s)
5050
end
5151

5252
def test_select

test/uri/test_generic.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ def test_merge
240240
u = URI.parse('http://foo/bar/baz')
241241
assert_equal(nil, u.merge!(""))
242242
assert_equal(nil, u.merge!(u))
243-
assert(nil != u.merge!("."))
243+
refute_nil(u.merge!("."))
244244
assert_equal('http://foo/bar/', u.to_s)
245-
assert(nil != u.merge!("../baz"))
245+
refute_nil(u.merge!("../baz"))
246246
assert_equal('http://foo/baz', u.to_s)
247247

248248
url = URI.parse('http://a/b//c') + 'd//e'
@@ -356,7 +356,7 @@ def test_rfc3986_examples
356356
assert_equal('http://a/b/c/g', url.to_s)
357357
url = @base_url.route_to('http://a/b/c/g')
358358
assert_kind_of(URI::Generic, url)
359-
assert('./g' != url.to_s) # ok
359+
refute_equal('./g', url.to_s) # ok
360360
assert_equal('g', url.to_s)
361361

362362
# http://a/b/c/d;p?q
@@ -375,7 +375,7 @@ def test_rfc3986_examples
375375
assert_equal('http://a/g', url.to_s)
376376
url = @base_url.route_to('http://a/g')
377377
assert_kind_of(URI::Generic, url)
378-
assert('/g' != url.to_s) # ok
378+
refute_equal('/g', url.to_s) # ok
379379
assert_equal('../../g', url.to_s)
380380

381381
# http://a/b/c/d;p?q
@@ -466,7 +466,7 @@ def test_rfc3986_examples
466466
assert_equal('http://a/b/c/', url.to_s)
467467
url = @base_url.route_to('http://a/b/c/')
468468
assert_kind_of(URI::Generic, url)
469-
assert('.' != url.to_s) # ok
469+
refute_equal('.', url.to_s) # ok
470470
assert_equal('./', url.to_s)
471471

472472
# http://a/b/c/d;p?q
@@ -485,7 +485,7 @@ def test_rfc3986_examples
485485
assert_equal('http://a/b/', url.to_s)
486486
url = @base_url.route_to('http://a/b/')
487487
assert_kind_of(URI::Generic, url)
488-
assert('..' != url.to_s) # ok
488+
refute_equal('..', url.to_s) # ok
489489
assert_equal('../', url.to_s)
490490

491491
# http://a/b/c/d;p?q
@@ -513,7 +513,7 @@ def test_rfc3986_examples
513513
assert_equal('http://a/', url.to_s)
514514
url = @base_url.route_to('http://a/')
515515
assert_kind_of(URI::Generic, url)
516-
assert('../..' != url.to_s) # ok
516+
refute_equal('../..', url.to_s) # ok
517517
assert_equal('../../', url.to_s)
518518

519519
# http://a/b/c/d;p?q
@@ -604,7 +604,7 @@ def test_rfc3986_examples
604604
assert_equal('http://a/g', url.to_s)
605605
url = @base_url.route_to('http://a/g')
606606
assert_kind_of(URI::Generic, url)
607-
assert('../../../g' != url.to_s) # ok? yes, it confuses you
607+
refute_equal('../../../g', url.to_s) # ok? yes, it confuses you
608608
assert_equal('../../g', url.to_s) # and it is clearly
609609

610610
# http://a/b/c/d;p?q
@@ -614,7 +614,7 @@ def test_rfc3986_examples
614614
assert_equal('http://a/g', url.to_s)
615615
url = @base_url.route_to('http://a/g')
616616
assert_kind_of(URI::Generic, url)
617-
assert('../../../../g' != url.to_s) # ok? yes, it confuses you
617+
refute_equal('../../../../g', url.to_s) # ok? yes, it confuses you
618618
assert_equal('../../g', url.to_s) # and it is clearly
619619

620620
# http://a/b/c/d;p?q
@@ -624,7 +624,7 @@ def test_rfc3986_examples
624624
assert_equal('http://a/b/g', url.to_s)
625625
url = @base_url.route_to('http://a/b/g')
626626
assert_kind_of(URI::Generic, url)
627-
assert('./../g' != url.to_s) # ok
627+
refute_equal('./../g', url.to_s) # ok
628628
assert_equal('../g', url.to_s)
629629

630630
# http://a/b/c/d;p?q
@@ -634,7 +634,7 @@ def test_rfc3986_examples
634634
assert_equal('http://a/b/c/g/', url.to_s)
635635
url = @base_url.route_to('http://a/b/c/g/')
636636
assert_kind_of(URI::Generic, url)
637-
assert('./g/.' != url.to_s) # ok
637+
refute_equal('./g/.', url.to_s) # ok
638638
assert_equal('g/', url.to_s)
639639

640640
# http://a/b/c/d;p?q
@@ -644,7 +644,7 @@ def test_rfc3986_examples
644644
assert_equal('http://a/b/c/g/h', url.to_s)
645645
url = @base_url.route_to('http://a/b/c/g/h')
646646
assert_kind_of(URI::Generic, url)
647-
assert('g/./h' != url.to_s) # ok
647+
refute_equal('g/./h', url.to_s) # ok
648648
assert_equal('g/h', url.to_s)
649649

650650
# http://a/b/c/d;p?q
@@ -654,7 +654,7 @@ def test_rfc3986_examples
654654
assert_equal('http://a/b/c/h', url.to_s)
655655
url = @base_url.route_to('http://a/b/c/h')
656656
assert_kind_of(URI::Generic, url)
657-
assert('g/../h' != url.to_s) # ok
657+
refute_equal('g/../h', url.to_s) # ok
658658
assert_equal('h', url.to_s)
659659

660660
# http://a/b/c/d;p?q
@@ -664,7 +664,7 @@ def test_rfc3986_examples
664664
assert_equal('http://a/b/c/g;x=1/y', url.to_s)
665665
url = @base_url.route_to('http://a/b/c/g;x=1/y')
666666
assert_kind_of(URI::Generic, url)
667-
assert('g;x=1/./y' != url.to_s) # ok
667+
refute_equal('g;x=1/./y', url.to_s) # ok
668668
assert_equal('g;x=1/y', url.to_s)
669669

670670
# http://a/b/c/d;p?q
@@ -674,7 +674,7 @@ def test_rfc3986_examples
674674
assert_equal('http://a/b/c/y', url.to_s)
675675
url = @base_url.route_to('http://a/b/c/y')
676676
assert_kind_of(URI::Generic, url)
677-
assert('g;x=1/../y' != url.to_s) # ok
677+
refute_equal('g;x=1/../y', url.to_s) # ok
678678
assert_equal('y', url.to_s)
679679

680680
# http://a/b/c/d;p?q
@@ -822,18 +822,18 @@ def test_hierarchical
822822
hierarchical = URI.parse('http://a.b.c/example')
823823
opaque = URI.parse('mailto:mduerst@ifi.unizh.ch')
824824

825-
assert hierarchical.hierarchical?
826-
refute opaque.hierarchical?
825+
assert_predicate hierarchical, :hierarchical?
826+
refute_predicate opaque, :hierarchical?
827827
end
828828

829829
def test_absolute
830830
abs_uri = URI.parse('http://a.b.c/')
831831
not_abs = URI.parse('a.b.c')
832832

833-
refute not_abs.absolute?
833+
refute_predicate not_abs, :absolute?
834834

835-
assert abs_uri.absolute
836-
assert abs_uri.absolute?
835+
assert_predicate abs_uri, :absolute
836+
assert_predicate abs_uri, :absolute?
837837
end
838838

839839
def test_ipv6

test/uri/test_http.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ def test_normalize
3333
host = 'aBcD'
3434
u1 = URI.parse('http://' + host + '/eFg?HiJ')
3535
u2 = URI.parse('http://' + host.downcase + '/eFg?HiJ')
36-
assert(u1.normalize.host == 'abcd')
37-
assert(u1.normalize.path == u1.path)
38-
assert(u1.normalize == u2.normalize)
39-
assert(!u1.normalize.host.equal?(u1.host))
40-
assert( u2.normalize.host.equal?(u2.host))
36+
assert_equal('abcd', u1.normalize.host)
37+
assert_equal(u1.path, u1.normalize.path)
38+
assert_equal(u2.normalize, u1.normalize)
39+
refute_same(u1.host, u1.normalize.host)
40+
assert_same(u2.host, u2.normalize.host)
4141

4242
assert_equal('http://abc/', URI.parse('http://abc').normalize.to_s)
4343
end
4444

4545
def test_equal
46-
assert(URI.parse('http://abc') == URI.parse('http://ABC'))
47-
assert(URI.parse('http://abc/def') == URI.parse('http://ABC/def'))
48-
assert(URI.parse('http://abc/def') != URI.parse('http://ABC/DEF'))
46+
assert_equal(URI.parse('http://ABC'), URI.parse('http://abc'))
47+
assert_equal(URI.parse('http://ABC/def'), URI.parse('http://abc/def'))
48+
refute_equal(URI.parse('http://ABC/DEF'), URI.parse('http://abc/def'))
4949
end
5050

5151
def test_request_uri

test/uri/test_parser.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def test_compare
2020
u2 = p.parse(url)
2121
u3 = p.parse(url)
2222

23-
assert(u0 == u1)
24-
assert(u0.eql?(u1))
25-
assert(!u0.equal?(u1))
23+
assert_equal(u1, u0)
24+
assert_send([u0, :eql?, u1])
25+
refute_same(u1, u0)
2626

27-
assert(u1 == u2)
28-
assert(!u1.eql?(u2))
29-
assert(!u1.equal?(u2))
27+
assert_equal(u2, u1)
28+
assert_not_send([u1, :eql?, u2])
29+
refute_same(u1, u2)
3030

31-
assert(u2 == u3)
32-
assert(u2.eql?(u3))
33-
assert(!u2.equal?(u3))
31+
assert_equal(u3, u2)
32+
assert_send([u2, :eql?, u3])
33+
refute_same(u3, u2)
3434
end
3535

3636
def test_parse_rfc2396_parser

test/uri/test_ws.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ def test_normalize
3131
host = 'aBcD'
3232
u1 = URI.parse('ws://' + host + '/eFg?HiJ')
3333
u2 = URI.parse('ws://' + host.downcase + '/eFg?HiJ')
34-
assert(u1.normalize.host == 'abcd')
35-
assert(u1.normalize.path == u1.path)
36-
assert(u1.normalize == u2.normalize)
37-
assert(!u1.normalize.host.equal?(u1.host))
38-
assert( u2.normalize.host.equal?(u2.host))
34+
assert_equal('abcd', u1.normalize.host)
35+
assert_equal(u1.path, u1.normalize.path)
36+
assert_equal(u2.normalize, u1.normalize)
37+
refute_same(u1.host, u1.normalize.host)
38+
assert_same(u2.host, u2.normalize.host)
3939

4040
assert_equal('ws://abc/', URI.parse('ws://abc').normalize.to_s)
4141
end
4242

4343
def test_equal
44-
assert(URI.parse('ws://abc') == URI.parse('ws://ABC'))
45-
assert(URI.parse('ws://abc/def') == URI.parse('ws://ABC/def'))
46-
assert(URI.parse('ws://abc/def') != URI.parse('ws://ABC/DEF'))
44+
assert_equal(URI.parse('ws://ABC'), URI.parse('ws://abc'))
45+
assert_equal(URI.parse('ws://ABC/def'), URI.parse('ws://abc/def'))
46+
refute_equal(URI.parse('ws://ABC/DEF'), URI.parse('ws://abc/def'))
4747
end
4848

4949
def test_request_uri

test/uri/test_wss.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ def test_normalize
3131
host = 'aBcD'
3232
u1 = URI.parse('wss://' + host + '/eFg?HiJ')
3333
u2 = URI.parse('wss://' + host.downcase + '/eFg?HiJ')
34-
assert(u1.normalize.host == 'abcd')
35-
assert(u1.normalize.path == u1.path)
36-
assert(u1.normalize == u2.normalize)
37-
assert(!u1.normalize.host.equal?(u1.host))
38-
assert( u2.normalize.host.equal?(u2.host))
34+
assert_equal('abcd', u1.normalize.host)
35+
assert_equal(u1.path, u1.normalize.path)
36+
assert_equal(u2.normalize, u1.normalize)
37+
refute_same(u1.host, u1.normalize.host)
38+
assert_same(u2.host, u2.normalize.host)
3939

4040
assert_equal('wss://abc/', URI.parse('wss://abc').normalize.to_s)
4141
end
4242

4343
def test_equal
44-
assert(URI.parse('wss://abc') == URI.parse('wss://ABC'))
45-
assert(URI.parse('wss://abc/def') == URI.parse('wss://ABC/def'))
46-
assert(URI.parse('wss://abc/def') != URI.parse('wss://ABC/DEF'))
44+
assert_equal(URI.parse('wss://ABC'), URI.parse('wss://abc'))
45+
assert_equal(URI.parse('wss://ABC/def'), URI.parse('wss://abc/def'))
46+
refute_equal(URI.parse('wss://ABC/DEF'), URI.parse('wss://abc/def'))
4747
end
4848

4949
def test_request_uri

0 commit comments

Comments
 (0)