ruby-changes:22834
From: tenderlove <ko1@a...>
Date: Sat, 3 Mar 2012 08:21:28 +0900 (JST)
Subject: [ruby-changes:22834] tenderlove:r34883 (trunk): * lib/xmlrpc/client.rb (new2): raises an ArgumentError on bad
tenderlove 2012-03-03 08:21:17 +0900 (Sat, 03 Mar 2012) New Revision: 34883 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34883 Log: * lib/xmlrpc/client.rb (new2): raises an ArgumentError on bad arguments. * test/xmlrpc/test_client.rb: tests for bad uris Modified files: trunk/ChangeLog trunk/lib/xmlrpc/client.rb trunk/test/xmlrpc/test_client.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34882) +++ ChangeLog (revision 34883) @@ -1,3 +1,9 @@ +Sat Mar 3 08:20:10 2012 Aaron Patterson <aaron@t...> + + * lib/xmlrpc/client.rb (new2): raises an ArgumentError on bad + arguments. + * test/xmlrpc/test_client.rb: tests for bad uris + Sat Mar 3 08:08:11 2012 Aaron Patterson <aaron@t...> * lib/xmlrpc/client.rb (new2): fix custom port specification when an Index: lib/xmlrpc/client.rb =================================================================== --- lib/xmlrpc/client.rb (revision 34882) +++ lib/xmlrpc/client.rb (revision 34883) @@ -349,12 +349,12 @@ when 'http' then port ||= 80 when 'https' then port ||= 443 else - raise "Wrong protocol specified. Only http or https allowed!" + raise ArgumentError, "Wrong protocol specified. Only http or https allowed!" end port = port.to_i else - raise "Wrong URI as parameter!" + raise ArgumentError, "Wrong URI as parameter!" end proxy_host, proxy_port = (proxy || "").split(":") Index: test/xmlrpc/test_client.rb =================================================================== --- test/xmlrpc/test_client.rb (revision 34882) +++ test/xmlrpc/test_client.rb (revision 34883) @@ -98,5 +98,39 @@ [ user, password, use_ssl, timeout ].each { |x| refute x } end + + def test_new2_no_path + client = FakeClient.new2 'http://example.org' + host, path, port, *rest = client.args + + assert_equal 'example.org', host + assert_nil path + assert port + + rest.each { |x| refute x } + end + + def test_new2_slash_path + client = FakeClient.new2 'http://example.org/' + host, path, port, *rest = client.args + + assert_equal 'example.org', host + assert_equal '/', path + assert port + + rest.each { |x| refute x } + end + + def test_new2_bad_protocol + assert_raises(ArgumentError) do + XMLRPC::Client.new2 'ftp://example.org' + end + end + + def test_new2_bad_uri + assert_raises(ArgumentError) do + XMLRPC::Client.new2 ':::::' + end + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/