diff options
Diffstat (limited to 'spec/ruby/library/uri/shared/parse.rb')
| -rw-r--r-- | spec/ruby/library/uri/shared/parse.rb | 37 |
1 files changed, 22 insertions, 15 deletions
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 |
