diff options
Diffstat (limited to 'spec/ruby/library/uri')
| -rw-r--r-- | spec/ruby/library/uri/generic/host_spec.rb | 5 | ||||
| -rw-r--r-- | spec/ruby/library/uri/generic/to_s_spec.rb | 5 | ||||
| -rw-r--r-- | spec/ruby/library/uri/join_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/uri/mailto/build_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/uri/parse_spec.rb | 24 | ||||
| -rw-r--r-- | spec/ruby/library/uri/plus_spec.rb | 170 | ||||
| -rw-r--r-- | spec/ruby/library/uri/select_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/uri/set_component_spec.rb | 60 | ||||
| -rw-r--r-- | spec/ruby/library/uri/shared/eql.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/uri/shared/join.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/uri/shared/parse.rb | 37 | ||||
| -rw-r--r-- | spec/ruby/library/uri/uri_spec.rb | 4 |
12 files changed, 169 insertions, 154 deletions
diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb index f2076d2bc1..4a5a162512 100644 --- a/spec/ruby/library/uri/generic/host_spec.rb +++ b/spec/ruby/library/uri/generic/host_spec.rb @@ -2,7 +2,10 @@ require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#host" do - it "needs to be reviewed for spec completeness" + # https://hackerone.com/reports/156615 + it "returns empty string when host is empty" do + URI.parse('http:////foo.com').host.should == '' + end end describe "URI::Generic#host=" do diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb index 8c90d7645b..c436ee3c03 100644 --- a/spec/ruby/library/uri/generic/to_s_spec.rb +++ b/spec/ruby/library/uri/generic/to_s_spec.rb @@ -2,5 +2,8 @@ require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#to_s" do - it "needs to be reviewed for spec completeness" + # https://hackerone.com/reports/156615 + it "preserves / characters when host is empty" do + URI('http:///foo.com').to_s.should == 'http:///foo.com' + end end diff --git a/spec/ruby/library/uri/join_spec.rb b/spec/ruby/library/uri/join_spec.rb index 796f74134f..1777303360 100644 --- a/spec/ruby/library/uri/join_spec.rb +++ b/spec/ruby/library/uri/join_spec.rb @@ -23,7 +23,7 @@ describe "URI.join" do it "raises an error if given no argument" do -> { URI.join - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't create redundant '/'s" do diff --git a/spec/ruby/library/uri/mailto/build_spec.rb b/spec/ruby/library/uri/mailto/build_spec.rb index 2c011626ab..081707b1cf 100644 --- a/spec/ruby/library/uri/mailto/build_spec.rb +++ b/spec/ruby/library/uri/mailto/build_spec.rb @@ -84,7 +84,7 @@ describe "URI::Mailto.build" do end bad.each do |x| - -> { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError) + -> { URI::MailTo.build(x) }.should.raise(URI::InvalidComponentError) end ok.flatten.join("\0").should == ok_all diff --git a/spec/ruby/library/uri/parse_spec.rb b/spec/ruby/library/uri/parse_spec.rb index e9ec59b490..f0373fbf5e 100644 --- a/spec/ruby/library/uri/parse_spec.rb +++ b/spec/ruby/library/uri/parse_spec.rb @@ -4,7 +4,7 @@ require_relative 'fixtures/classes' describe "URI.parse" do it "returns a URI::HTTP object when parsing an HTTP URI" do - URI.parse("http://www.example.com/").should be_kind_of(URI::HTTP) + URI.parse("http://www.example.com/").should.is_a?(URI::HTTP) end it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do @@ -47,7 +47,7 @@ describe "URI.parse" do end it "returns a URI::HTTPS object when parsing an HTTPS URI" do - URI.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) + URI.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) end it "sets the port of a parsed https URI to 443 by default" do @@ -57,7 +57,7 @@ describe "URI.parse" do it "populates the components of a parsed URI::FTP object" do # generic, empty password. url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: "anonymous", @@ -69,7 +69,7 @@ describe "URI.parse" do # multidomain, no user or password url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: nil, @@ -81,7 +81,7 @@ describe "URI.parse" do # empty user url = URI.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: ":pass", @@ -97,7 +97,7 @@ describe "URI.parse" do #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } ldap_uris.each do |ldap_uri| - URI.parse(ldap_uri).should be_kind_of(URI::LDAP) + URI.parse(ldap_uri).should.is_a?(URI::LDAP) end end @@ -115,7 +115,7 @@ describe "URI.parse" do end it "returns a URI::MailTo object when passed a mailto URI" do - URI.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) + URI.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) end it "populates the components of a parsed URI::MailTo object" do @@ -145,7 +145,7 @@ describe "URI.parse" do # gopher gopher = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) + gopher.should.is_a?(URI::Generic) URISpec.components(gopher).should == { scheme: "gopher", @@ -161,7 +161,7 @@ describe "URI.parse" do # news news = URI.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) + news.should.is_a?(URI::Generic) URISpec.components(news).should == { scheme: "news", userinfo: nil, @@ -176,7 +176,7 @@ describe "URI.parse" do # telnet telnet = URI.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) + telnet.should.is_a?(URI::Generic) URISpec.components(telnet).should == { scheme: "telnet", userinfo: nil, @@ -191,9 +191,9 @@ describe "URI.parse" do # files file_l = URI.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) + file_l.should.is_a?(URI::Generic) file = URI.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) + file.should.is_a?(URI::Generic) end it "doesn't raise errors on URIs which has underscore in reg_name" do diff --git a/spec/ruby/library/uri/plus_spec.rb b/spec/ruby/library/uri/plus_spec.rb index b84b0767c1..51fb5e3750 100644 --- a/spec/ruby/library/uri/plus_spec.rb +++ b/spec/ruby/library/uri/plus_spec.rb @@ -36,7 +36,7 @@ describe "URI#+" do end it "raises a URI::BadURIError when adding two relative URIs" do - -> {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError) + -> {URI.parse('a/b/c') + "d"}.should.raise(URI::BadURIError) end #Todo: make more BDD? @@ -47,403 +47,403 @@ describe "URI#+" do # http://a/b/c/d;p?q # g:h = g:h url = @base_url.merge('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' url = @base_url.route_to('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' # http://a/b/c/d;p?q # g = http://a/b/c/g url = @base_url.merge('g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g' # http://a/b/c/d;p?q # ./g = http://a/b/c/g url = @base_url.merge('./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g' # ok url.to_s.should == 'g' # http://a/b/c/d;p?q # g/ = http://a/b/c/g/ url = @base_url.merge('g/') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g/' # http://a/b/c/d;p?q # /g = http://a/g url = @base_url.merge('/g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '/g' # ok url.to_s.should == '../../g' # http://a/b/c/d;p?q # //g = http://g url = @base_url.merge('//g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://g' url = @base_url.route_to('http://g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '//g' # http://a/b/c/d;p?q # ?y = http://a/b/c/?y url = @base_url.merge('?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?y' url = @base_url.route_to('http://a/b/c/?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '?y' # http://a/b/c/d;p?q # g?y = http://a/b/c/g?y url = @base_url.merge('g?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y' url = @base_url.route_to('http://a/b/c/g?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y' # http://a/b/c/d;p?q # #s = (current document)#s url = @base_url.merge('#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == @base_url.to_s + '#s' url = @base_url.route_to(@base_url.to_s + '#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '#s' # http://a/b/c/d;p?q # g#s = http://a/b/c/g#s url = @base_url.merge('g#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s' url = @base_url.route_to('http://a/b/c/g#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s' # http://a/b/c/d;p?q # g?y#s = http://a/b/c/g?y#s url = @base_url.merge('g?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y#s' url = @base_url.route_to('http://a/b/c/g?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y#s' # http://a/b/c/d;p?q # ;x = http://a/b/c/;x url = @base_url.merge(';x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/;x' url = @base_url.route_to('http://a/b/c/;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == ';x' # http://a/b/c/d;p?q # g;x = http://a/b/c/g;x url = @base_url.merge('g;x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x' url = @base_url.route_to('http://a/b/c/g;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x' # http://a/b/c/d;p?q # g;x?y#s = http://a/b/c/g;x?y#s url = @base_url.merge('g;x?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x?y#s' url = @base_url.route_to('http://a/b/c/g;x?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x?y#s' # http://a/b/c/d;p?q # . = http://a/b/c/ url = @base_url.merge('.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '.' # ok url.to_s.should == './' # http://a/b/c/d;p?q # ./ = http://a/b/c/ url = @base_url.merge('./') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == './' # http://a/b/c/d;p?q # .. = http://a/b/ url = @base_url.merge('..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '..' # ok url.to_s.should == '../' # http://a/b/c/d;p?q # ../ = http://a/b/ url = @base_url.merge('../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../' # http://a/b/c/d;p?q # ../g = http://a/b/g url = @base_url.merge('../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../g' # http://a/b/c/d;p?q # ../.. = http://a/ url = @base_url.merge('../..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../..' # ok url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../ = http://a/ url = @base_url.merge('../../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../g = http://a/g url = @base_url.merge('../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../g' # http://a/b/c/d;p?q # <> = (current document) url = @base_url.merge('') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?q' url = @base_url.route_to('http://a/b/c/d;p?q') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '' # http://a/b/c/d;p?q # /./g = http://a/./g url = @base_url.merge('/./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/./g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/./g' # http://a/b/c/d;p?q # /../g = http://a/../g url = @base_url.merge('/../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/../g' # http://a/b/c/d;p?q # g. = http://a/b/c/g. url = @base_url.merge('g.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g.' url = @base_url.route_to('http://a/b/c/g.') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g.' # http://a/b/c/d;p?q # .g = http://a/b/c/.g url = @base_url.merge('.g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/.g' url = @base_url.route_to('http://a/b/c/.g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '.g' # http://a/b/c/d;p?q # g.. = http://a/b/c/g.. url = @base_url.merge('g..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g..' url = @base_url.route_to('http://a/b/c/g..') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g..' # http://a/b/c/d;p?q # ..g = http://a/b/c/..g url = @base_url.merge('..g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/..g' url = @base_url.route_to('http://a/b/c/..g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '..g' # http://a/b/c/d;p?q # ../../../g = http://a/../g url = @base_url.merge('../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../g' # ok? yes, it confuses you url.to_s.should == '/../g' # and it is clearly # http://a/b/c/d;p?q # ../../../../g = http://a/../../g url = @base_url.merge('../../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../../g' # ok? yes, it confuses you url.to_s.should == '/../../g' # and it is clearly # http://a/b/c/d;p?q # ./../g = http://a/b/g url = @base_url.merge('./../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './../g' # ok url.to_s.should == '../g' # http://a/b/c/d;p?q # ./g/. = http://a/b/c/g/ url = @base_url.merge('./g/.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g/.' # ok url.to_s.should == 'g/' # http://a/b/c/d;p?q # g/./h = http://a/b/c/g/h url = @base_url.merge('g/./h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/h' url = @base_url.route_to('http://a/b/c/g/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/./h' # ok url.to_s.should == 'g/h' # http://a/b/c/d;p?q # g/../h = http://a/b/c/h url = @base_url.merge('g/../h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/h' url = @base_url.route_to('http://a/b/c/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/../h' # ok url.to_s.should == 'h' # http://a/b/c/d;p?q # g;x=1/./y = http://a/b/c/g;x=1/y url = @base_url.merge('g;x=1/./y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x=1/y' url = @base_url.route_to('http://a/b/c/g;x=1/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/./y' # ok url.to_s.should == 'g;x=1/y' # http://a/b/c/d;p?q # g;x=1/../y = http://a/b/c/y url = @base_url.merge('g;x=1/../y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/y' url = @base_url.route_to('http://a/b/c/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/../y' # ok url.to_s.should == 'y' # http://a/b/c/d;p?q # g?y/./x = http://a/b/c/g?y/./x url = @base_url.merge('g?y/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/./x' url = @base_url.route_to('http://a/b/c/g?y/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/./x' # http://a/b/c/d;p?q # g?y/../x = http://a/b/c/g?y/../x url = @base_url.merge('g?y/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/../x' url = @base_url.route_to('http://a/b/c/g?y/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/../x' # http://a/b/c/d;p?q # g#s/./x = http://a/b/c/g#s/./x url = @base_url.merge('g#s/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/./x' url = @base_url.route_to('http://a/b/c/g#s/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/./x' # http://a/b/c/d;p?q # g#s/../x = http://a/b/c/g#s/../x url = @base_url.merge('g#s/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/../x' url = @base_url.route_to('http://a/b/c/g#s/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/../x' # http://a/b/c/d;p?q # http:g = http:g ; for validating parsers # | http://a/b/c/g ; for backwards compatibility url = @base_url.merge('http:g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http:g' url = @base_url.route_to('http:g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'http:g' end end diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb index 839b68b3a1..27591f69f2 100644 --- a/spec/ruby/library/uri/select_spec.rb +++ b/spec/ruby/library/uri/select_spec.rb @@ -15,13 +15,13 @@ describe "URI#select" do end it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do - -> { URI("mailto:spam@mailinator.com").select(:path) }.should raise_error(ArgumentError) - -> { URI("http://blog.blag.web").select(:typecode) }.should raise_error(ArgumentError) + -> { URI("mailto:spam@mailinator.com").select(:path) }.should.raise(ArgumentError) + -> { URI("http://blog.blag.web").select(:typecode) }.should.raise(ArgumentError) end it "raises an ArgumentError if given strings rather than symbols" do -> { URI("http://host:8080/path/").select("scheme","host","port",'path') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/uri/set_component_spec.rb b/spec/ruby/library/uri/set_component_spec.rb index 642a5d6fcf..15f1ed1f87 100644 --- a/spec/ruby/library/uri/set_component_spec.rb +++ b/spec/ruby/library/uri/set_component_spec.rb @@ -6,40 +6,42 @@ describe "URI#select" do it "conforms to the MatzRuby tests" do uri = URI.parse('http://foo:bar@baz') (uri.user = 'oof').should == 'oof' - uri.to_s.should == 'http://oof:bar@baz' - (uri.password = 'rab').should == 'rab' - uri.to_s.should == 'http://oof:rab@baz' - (uri.userinfo = 'foo').should == 'foo' - uri.to_s.should == 'http://foo:rab@baz' - (uri.userinfo = ['foo', 'bar']).should == ['foo', 'bar'] - uri.to_s.should == 'http://foo:bar@baz' - (uri.userinfo = ['foo']).should == ['foo'] - uri.to_s.should == 'http://foo:bar@baz' - (uri.host = 'zab').should == 'zab' - uri.to_s.should == 'http://foo:bar@zab' - (uri.port = 8080).should == 8080 - uri.to_s.should == 'http://foo:bar@zab:8080' - (uri.path = '/').should == '/' - uri.to_s.should == 'http://foo:bar@zab:8080/' - (uri.query = 'a=1').should == 'a=1' - uri.to_s.should == 'http://foo:bar@zab:8080/?a=1' - (uri.fragment = 'b123').should == 'b123' - uri.to_s.should == 'http://foo:bar@zab:8080/?a=1#b123' + version_is(URI::VERSION, "1.0.4") do + uri.to_s.should == 'http://oof@baz' + (uri.password = 'rab').should == 'rab' + uri.to_s.should == 'http://oof:rab@baz' + (uri.userinfo = 'foo').should == 'foo' + uri.to_s.should == 'http://foo@baz' + (uri.userinfo = ['foo', 'bar']).should == ['foo', 'bar'] + uri.to_s.should == 'http://foo:bar@baz' + (uri.userinfo = ['foo']).should == ['foo'] + uri.to_s.should == 'http://foo@baz' + (uri.host = 'zab').should == 'zab' + uri.to_s.should == 'http://zab' + (uri.port = 8080).should == 8080 + uri.to_s.should == 'http://zab:8080' + (uri.path = '/').should == '/' + uri.to_s.should == 'http://zab:8080/' + (uri.query = 'a=1').should == 'a=1' + uri.to_s.should == 'http://zab:8080/?a=1' + (uri.fragment = 'b123').should == 'b123' + uri.to_s.should == 'http://zab:8080/?a=1#b123' + end uri = URI.parse('http://example.com') - -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) uri.userinfo = 'foo:bar' uri.to_s.should == 'http://foo:bar@example.com' - -> { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.registry = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.opaque = 'bar' }.should.raise(URI::InvalidURIError) uri = URI.parse('mailto:foo@example.com') - -> { uri.user = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError) - -> { uri.host = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.port = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.path = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.query = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.user = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.userinfo = ['bar', 'baz'] }.should.raise(URI::InvalidURIError) + -> { uri.host = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.port = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.path = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.query = 'bar' }.should.raise(URI::InvalidURIError) end end diff --git a/spec/ruby/library/uri/shared/eql.rb b/spec/ruby/library/uri/shared/eql.rb index 2cc960d39a..978c4aae05 100644 --- a/spec/ruby/library/uri/shared/eql.rb +++ b/spec/ruby/library/uri/shared/eql.rb @@ -3,7 +3,7 @@ describe :uri_eql, shared: true do URISpec::NORMALIZED_FORMS.each do |form| normal_uri = URI(form[:normalized]) form[:different].each do |other| - URI(other).send(@method, normal_uri).should be_false + URI(other).send(@method, normal_uri).should == false end end end @@ -11,7 +11,7 @@ end describe :uri_eql_against_other_types, shared: true do it "returns false for when compared to non-uri objects" do - URI("http://example.com/").send(@method, "http://example.com/").should be_false - URI("http://example.com/").send(@method, nil).should be_false + URI("http://example.com/").send(@method, "http://example.com/").should == false + URI("http://example.com/").send(@method, nil).should == false end end diff --git a/spec/ruby/library/uri/shared/join.rb b/spec/ruby/library/uri/shared/join.rb index 4df0782b37..b1f5f1c72b 100644 --- a/spec/ruby/library/uri/shared/join.rb +++ b/spec/ruby/library/uri/shared/join.rb @@ -20,7 +20,7 @@ describe :uri_join, shared: true do it "raises an error if given no argument" do -> { @object.join - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't create redundant '/'s" do diff --git a/spec/ruby/library/uri/shared/parse.rb b/spec/ruby/library/uri/shared/parse.rb index 87e1ee933e..7ec7179526 100644 --- a/spec/ruby/library/uri/shared/parse.rb +++ b/spec/ruby/library/uri/shared/parse.rb @@ -1,6 +1,6 @@ describe :uri_parse, shared: true do it "returns a URI::HTTP object when parsing an HTTP URI" do - @object.parse("http://www.example.com/").should be_kind_of(URI::HTTP) + @object.parse("http://www.example.com/").should.is_a?(URI::HTTP) end it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do @@ -43,7 +43,7 @@ describe :uri_parse, shared: true do end it "returns a URI::HTTPS object when parsing an HTTPS URI" do - @object.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) + @object.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) end it "sets the port of a parsed https URI to 443 by default" do @@ -53,7 +53,7 @@ describe :uri_parse, shared: true do it "populates the components of a parsed URI::FTP object" do # generic, empty password. url = @object.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: "anonymous", @@ -65,7 +65,7 @@ describe :uri_parse, shared: true do # multidomain, no user or password url = @object.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: nil, @@ -77,7 +77,7 @@ describe :uri_parse, shared: true do # empty user url = @object.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: ":pass", @@ -93,7 +93,7 @@ describe :uri_parse, shared: true do #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } ldap_uris.each do |ldap_uri| - @object.parse(ldap_uri).should be_kind_of(URI::LDAP) + @object.parse(ldap_uri).should.is_a?(URI::LDAP) end end @@ -111,7 +111,7 @@ describe :uri_parse, shared: true do end it "returns a URI::MailTo object when passed a mailto URI" do - @object.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) + @object.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) end it "populates the components of a parsed URI::MailTo object" do @@ -141,7 +141,7 @@ describe :uri_parse, shared: true do # gopher gopher = @object.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) + gopher.should.is_a?(URI::Generic) URISpec.components(gopher).should == { scheme: "gopher", @@ -157,7 +157,7 @@ describe :uri_parse, shared: true do # news news = @object.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) + news.should.is_a?(URI::Generic) URISpec.components(news).should == { scheme: "news", userinfo: nil, @@ -172,7 +172,7 @@ describe :uri_parse, shared: true do # telnet telnet = @object.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) + telnet.should.is_a?(URI::Generic) URISpec.components(telnet).should == { scheme: "telnet", userinfo: nil, @@ -187,13 +187,20 @@ describe :uri_parse, shared: true do # files file_l = @object.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) + file_l.should.is_a?(URI::Generic) file = @object.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) + file.should.is_a?(URI::Generic) end - it "raises errors on malformed URIs" do - -> { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError) - -> { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError) + if URI::DEFAULT_PARSER == URI::RFC2396_Parser + it "raises errors on malformed URIs" do + -> { @object.parse('http://a_b:80/') }.should.raise(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should.raise(URI::InvalidURIError) + end + elsif URI::DEFAULT_PARSER == URI::RFC3986_Parser + it "does not raise errors on URIs contained underscore" do + -> { @object.parse('http://a_b:80/') }.should_not.raise(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should_not.raise(URI::InvalidURIError) + end end end diff --git a/spec/ruby/library/uri/uri_spec.rb b/spec/ruby/library/uri/uri_spec.rb index 45a7502052..eab4e7176c 100644 --- a/spec/ruby/library/uri/uri_spec.rb +++ b/spec/ruby/library/uri/uri_spec.rb @@ -19,11 +19,11 @@ describe "the URI method" do it "returns the argument if it is a URI object" do result = URI.parse("http://ruby-lang.org") - URI(result).should equal(result) + URI(result).should.equal?(result) end #apparently this was a concern? imported from MRI tests it "does not add a URI method to Object instances" do - -> {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError) + -> {Object.new.URI("http://ruby-lang.org/")}.should.raise(NoMethodError) end end |
