Sha256: 15c5fe0f524de3ca8f63ea1d53b7a9454b4ecc8acde0e2050ab137f83670943b
Contents?: true
Size: 793 Bytes
Versions: 12
Compression:
Stored size: 793 Bytes
Contents
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') require 'mongo' include Mongo host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT puts "Connecting to #{host}:#{port}" db = Connection.new(host, port).db('ruby-mongo-examples') db.drop_collection('does-not-exist') db.create_collection('test') db.strict = true begin # Can't reference collection that does not exist db.collection('does-not-exist') puts "error: expected exception" rescue => ex puts "expected exception: #{ex}" end begin # Can't create collection that already exists db.create_collection('test') puts "error: expected exception" rescue => ex puts "expected exception: #{ex}" end db.strict = false db.drop_collection('test')
Version data entries
12 entries across 12 versions & 3 rubygems