spec/low/mongo_spec.rb in low-0.0.3 vs spec/low/mongo_spec.rb in low-0.0.4
- old
+ new
@@ -57,15 +57,39 @@
it 'should return \'localhost\' if none was specified at initialization' do
mongo = Low::Mongo::Local.new('low_test')
mongo.host.should == 'localhost'
end
- it 'should return the value specified at initialization' do
- mongo = Low::Mongo::Local.new('low_test', '0.0.0.0')
+ it 'should return the value specified by the named parameter at initialization' do
+ mongo = Low::Mongo::Local.new('low_test', host: '0.0.0.0')
mongo.host.should == '0.0.0.0'
end
end
+
+ describe '#username' do
+ it 'should return nil if none is specified at initialization' do
+ mongo = Low::Mongo::Local.new('low_test')
+ mongo.username.should be_nil
+ end
+
+ it 'should return the value specified by the named parameter at initialization' do
+ mongo = Low::Mongo::Local.new('low_test', username: 'khy')
+ mongo.username.should == 'khy'
+ end
+ end
+
+ describe '#password' do
+ it 'should return nil if none is specified at initialization' do
+ mongo = Low::Mongo::Local.new('low_test')
+ mongo.username.should be_nil
+ end
+
+ it 'should return the value specified by the named parameter at initialization' do
+ mongo = Low::Mongo::Local.new('low_test', password: 'secret')
+ mongo.password.should == 'secret'
+ end
+ end
end
describe Low::Mongo::Remote do
describe '#uri' do
it 'should return the value specified at initialization' do
@@ -76,9 +100,33 @@
describe '#database' do
it 'should return a value extracted from the URI' do
mongo = Low::Mongo::Remote.new('mongodb://khy:secret@mongo.com/low_remote')
mongo.database.should == 'low_remote'
+ end
+ end
+
+ describe '#username' do
+ it 'should return nil if the URI does not specify a username' do
+ mongo = Low::Mongo::Remote.new('mongodb://mongo.com/low_remote')
+ mongo.username.should be_nil
+ end
+
+ it 'should return the appropriate value extracted from the URI' do
+ mongo = Low::Mongo::Remote.new('mongodb://khy:secret@mongo.com/low_remote')
+ mongo.username.should == 'khy'
+ end
+ end
+
+ describe '#password' do
+ it 'should return nil if the URI does not specify a password' do
+ mongo = Low::Mongo::Remote.new('mongodb://mongo.com/low_remote')
+ mongo.password.should be_nil
+ end
+
+ it 'should return the appropriate value extracted from the URI' do
+ mongo = Low::Mongo::Remote.new('mongodb://khy:secret@mongo.com/low_remote')
+ mongo.password.should == 'secret'
end
end
describe '#connection' do
it 'should pass uri to the ::Mongo::Connection.from_uri method' do