Added options for host:port through ENV to connect to the server
This commit is contained in:
parent
66c3ed3b6e
commit
4c7873f3db
|
@ -1,4 +1,5 @@
|
|||
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
|
||||
require 'mongo'
|
||||
require 'test/unit'
|
||||
|
||||
|
@ -6,7 +7,9 @@ require 'test/unit'
|
|||
class DBAPITest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@db = XGen::Mongo::Driver::Mongo.new.db('ruby-mongo-test')
|
||||
host = ENV['HOST'] || ENV['host'] || 'localhost'
|
||||
port = ENV['PORT'] || ENV['port'] || 27017
|
||||
@db = XGen::Mongo::Driver::Mongo.new(host, port).db('ruby-mongo-test')
|
||||
@coll = @db.collection('test')
|
||||
@coll.clear
|
||||
@coll.insert('a' => 1) # collection not created until it's used
|
||||
|
|
|
@ -6,7 +6,9 @@ require 'test/unit'
|
|||
class DBConnectionTest < Test::Unit::TestCase
|
||||
|
||||
def test_no_exceptions
|
||||
db = XGen::Mongo::Driver::Mongo.new.db('ruby-mongo-demo')
|
||||
host = ENV['HOST'] || ENV['host'] || 'localhost'
|
||||
port = ENV['PORT'] || ENV['port'] || 27017
|
||||
db = XGen::Mongo::Driver::Mongo.new(host, port).db('ruby-mongo-test')
|
||||
coll = db.collection('test')
|
||||
coll.clear
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue