Sha256: ac61c2a7273cb5532d19aad54852a18954837bdb46b965ed2bd3ab0eca41d36a

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe MongoModel do
  after(:all) do
    MongoModel.configuration = {}
  end
  
  describe "setting a custom database configuration" do
    before(:each) do
      MongoModel.configuration = {
        'host'     => '127.0.0.1',
        'database' => 'mydb'
      }
    end
    
    it "should should merge configuration with defaults" do
      MongoModel.configuration.host.should == '127.0.0.1'
      MongoModel.configuration.port.should == 27017
      MongoModel.configuration.database.should == 'mydb'
    end
    
    it "should establish database connection to given database" do
      database = MongoModel.database
      connection = database.connection

      connection.host.should == '127.0.0.1'
      connection.port.should == 27017
      database.name.should == 'mydb'
    end
  end
  
  describe "setting a custom database configuration as a URI string" do
    before(:each) do
      MongoModel.configuration = "mongodb://127.0.0.2:27019/mydb"
    end
    
    it "should should merge configuration with defaults" do
      MongoModel.configuration.host.should == '127.0.0.2'
      MongoModel.configuration.port.should == 27019
      MongoModel.configuration.database.should == 'mydb'
    end
  end
  
  it "should have a logger accessor" do
    logger = mock('logger')
    MongoModel.logger = logger
    MongoModel.logger.should == logger
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongomodel-0.2.15 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.14 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.13 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.12 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.11 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.10 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.9 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.8 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.7 spec/mongomodel/mongomodel_spec.rb
mongomodel-0.2.6 spec/mongomodel/mongomodel_spec.rb