diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 2a365d7..9ba1dd5 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -22,7 +22,7 @@ class ConnectionTest < Test::Unit::TestCase context "given a single node" do setup do TCPSocket.stubs(:new).returns(new_mock_socket) - @conn = Connection.new('localhost', 27107, :connect => false) + @conn = Connection.new('localhost', 27017, :connect => false) admin_db = new_mock_db admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}) @@ -45,6 +45,22 @@ class ConnectionTest < Test::Unit::TestCase end end + context "with a nonstandard port" do + setup do + TCPSocket.stubs(:new).returns(new_mock_socket) + @conn = Connection.new('255.255.255.255', 2500, :connect => false) + admin_db = new_mock_db + admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}) + @conn.expects(:[]).with('admin').returns(admin_db) + @conn.connect_to_master + end + + should "set localhost and port correctly" do + assert_equal '255.255.255.255', @conn.host + assert_equal 2500, @conn.port + end + end + context "Connection pooling: " do setup do TCPSocket.stubs(:new).returns(new_mock_socket)