Sha256: 3d19f4493d1fed6817d35816b34b5368c637005199e8da40fed194c4e72b47e1

Contents?: true

Size: 1.64 KB

Versions: 61

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

class Address; end

class MongoMapperTest < Test::Unit::TestCase  
  should "be able to write and read connection" do
    conn = Mongo::Connection.new
    MongoMapper.connection = conn
    MongoMapper.connection.should == conn
  end
  
  should "default connection to new mongo ruby driver" do
    MongoMapper.connection = nil
    MongoMapper.connection.should be_instance_of(Mongo::Connection)
  end
  
  should "be able to write and read default database" do
    MongoMapper.database = 'test'
    MongoMapper.database.should be_instance_of(Mongo::DB)
    MongoMapper.database.name.should == 'test'
  end
  
  should "have document not found error" do
    lambda {
      MongoMapper::DocumentNotFound
    }.should_not raise_error
  end
  
  context "use_time_zone?" do
    should "be true if Time.zone set" do
      Time.zone = 'Hawaii'
      MongoMapper.use_time_zone?.should be_true
      Time.zone = nil
    end
    
    should "be false if Time.zone not set" do
      MongoMapper.use_time_zone?.should be_false
    end
  end
  
  context "time_class" do
    should "be Time.zone if using time zones" do
      Time.zone = 'Hawaii'
      MongoMapper.time_class.should == Time.zone
      Time.zone = nil
    end
    
    should "be Time if not using time zones" do
      MongoMapper.time_class.should == Time
    end
  end
  
  context "normalize_object_id" do
    should "turn string into object id" do
      id = Mongo::ObjectID.new
      MongoMapper.normalize_object_id(id.to_s).should == id
    end
    
    should "leave object id alone" do
      id = Mongo::ObjectID.new
      MongoMapper.normalize_object_id(id).should == id
    end
  end
  
end

Version data entries

61 entries across 61 versions & 9 rubygems

Version Path
drogus-mongo_mapper-0.6.10 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.8 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.5 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.4 test/unit/test_mongo_mapper.rb
novelys_mongo_mapper-0.6.12 test/unit/test_mongo_mapper.rb
novelys_mongo_mapper-0.6.11 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.3 test/unit/test_mongo_mapper.rb
novelys_mongo_mapper-0.6.10 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.2 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.2.1 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.31 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.30 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.29 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.28 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.27 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.26 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.25 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.22 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.21 test/unit/test_mongo_mapper.rb
mongo_mapper-unstable-2010.1.20 test/unit/test_mongo_mapper.rb