From 69598857ef198b8a4d21100e7b7d98dcf10dfe31 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 26 Sep 2011 16:27:10 -0400 Subject: [PATCH] minor: tests --- test/unit/connection_test.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index a7ea223..e7929bd 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -40,6 +40,12 @@ class ConnectionTest < Test::Unit::TestCase assert_equal [host_name, 27017], @conn.host_to_try end + should "allow db without username and password" do + host_name = "foo.bar-12345.org" + @conn = Connection.from_uri("mongodb://#{host_name}/foo", :connect => false) + assert_equal [host_name, 27017], @conn.host_to_try + end + should "parse a uri with a hyphen & underscore in the username or password" do @conn = Connection.from_uri("mongodb://hyphen-user_name:p-s_s@localhost:27017/db", :connect => false) assert_equal ['localhost', 27017], @conn.host_to_try @@ -71,10 +77,8 @@ class ConnectionTest < Test::Unit::TestCase end end - should "require all of username, password, and database if any one is specified" do - assert_raise MongoArgumentError do - Connection.from_uri("mongodb://localhost/db", :connect => false) - end + should "require all of username, if password and db are specified" do + assert Connection.from_uri("mongodb://kyle:jones@localhost/db", :connect => false) assert_raise MongoArgumentError do Connection.from_uri("mongodb://kyle:password@localhost", :connect => false)