@@ -24,14 +24,16 @@ def test_build
2424 def test_parse
2525 u = URI . parse ( 'http://a' )
2626 assert_kind_of ( URI ::HTTP , u )
27- assert_equal ( [ 'http' ,
28- nil , 'a' , URI ::HTTP . default_port ,
29- '' , nil , nil ] , uri_to_ary ( u ) )
27+ assert_equal ( [
28+ 'http' ,
29+ nil , 'a' , URI ::HTTP . default_port ,
30+ '' , nil , nil
31+ ] , uri_to_ary ( u ) )
3032 end
3133
3234 def test_normalize
3335 host = 'aBcD'
34- u1 = URI . parse ( 'http://' + host + '/eFg?HiJ' )
36+ u1 = URI . parse ( 'http://' + host + '/eFg?HiJ' )
3537 u2 = URI . parse ( 'http://' + host . downcase + '/eFg?HiJ' )
3638 assert ( u1 . normalize . host == 'abcd' )
3739 assert ( u1 . normalize . path == u1 . path )
@@ -49,11 +51,11 @@ def test_equal
4951 end
5052
5153 def test_request_uri
52- assert_equal ( '/' , URI . parse ( 'http://a.b.c/' ) . request_uri )
54+ assert_equal ( '/' , URI . parse ( 'http://a.b.c/' ) . request_uri )
5355 assert_equal ( '/?abc=def' , URI . parse ( 'http://a.b.c/?abc=def' ) . request_uri )
54- assert_equal ( '/' , URI . parse ( 'http://a.b.c' ) . request_uri )
56+ assert_equal ( '/' , URI . parse ( 'http://a.b.c' ) . request_uri )
5557 assert_equal ( '/?abc=def' , URI . parse ( 'http://a.b.c?abc=def' ) . request_uri )
56- assert_equal ( nil , URI . parse ( 'http:foo' ) . request_uri )
58+ assert_equal ( nil , URI . parse ( 'http:foo' ) . request_uri )
5759 end
5860
5961 def test_select
@@ -64,6 +66,20 @@ def test_select
6466 u . select ( :scheme , :host , :not_exist , :port )
6567 end
6668 end
69+
70+ def test_authority
71+ assert_equal ( 'a.b.c' , URI . parse ( 'http://a.b.c/' ) . authority )
72+ assert_equal ( 'a.b.c:8081' , URI . parse ( 'http://a.b.c:8081/' ) . authority )
73+ assert_equal ( 'a.b.c' , URI . parse ( 'http://a.b.c:80/' ) . authority )
74+ end
75+
76+
77+ def test_origin
78+ assert_equal ( 'http://a.b.c' , URI . parse ( 'http://a.b.c/' ) . origin )
79+ assert_equal ( 'http://a.b.c:8081' , URI . parse ( 'http://a.b.c:8081/' ) . origin )
80+ assert_equal ( 'http://a.b.c' , URI . parse ( 'http://a.b.c:80/' ) . origin )
81+ assert_equal ( 'https://a.b.c' , URI . parse ( 'https://a.b.c/' ) . origin )
82+ end
6783end
6884
6985
0 commit comments