require 'spec' require 'ruby_ext' require "mongo" require 'mongo_mapper' require "#{File.dirname __FILE__}/../../lib/mongo_mapper_ext/micelaneous" describe "MongoMapper Default Scope" do before :all do @db = Mongo::Connection.new.db('test') end before :each do @db.collection('test').drop @coll = @db.collection('test') end it "usert should update" do id = @coll.save :count => 2 @coll.upsert id, :$inc => {:count => 1} @coll.find(:_id => id).first['count'].should == 3 end it "usert should set" do id = @coll.save({}) @coll.upsert id, :$inc => {:count => 1} @coll.find(:_id => id).first['count'].should == 1 end end