Sha256: c78c17208338f38476ed00d6adf338853e17a11591734fe88bf097048601921e

Contents?: true

Size: 1.89 KB

Versions: 6

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe Apartment do

  describe "#config" do

    let(:excluded_models){ [Company] }

    it "should yield the Apartment object" do
      Apartment.configure do |config|
        config.excluded_models = []
        config.should == Apartment
      end
    end

    it "should set excluded models" do
      Apartment.configure do |config|
        config.excluded_models = excluded_models
      end
      Apartment.excluded_models.should == excluded_models
    end

    it "should set postgres_schemas" do
      Apartment.configure do |config|
        config.excluded_models = []
        config.use_postgres_schemas = false
      end
      Apartment.use_postgres_schemas.should be_false
    end

    it "should set seed_after_create" do
      Apartment.configure do |config|
        config.excluded_models = []
        config.seed_after_create = true
      end
      Apartment.seed_after_create.should be_true
    end

    context "databases" do
      it "should return object if it doesnt respond_to call" do
        database_names = ['users', 'companies']

        Apartment.configure do |config|
          config.excluded_models = []
          config.database_names = database_names
        end
        Apartment.database_names.should == database_names
      end

      it "should invoke the proc if appropriate" do
        database_names = lambda{ ['users', 'users'] }
        database_names.should_receive(:call)

        Apartment.configure do |config|
          config.excluded_models = []
          config.database_names = database_names
        end
        Apartment.database_names
      end

      it "should return the invoked proc if appropriate" do
        dbs = lambda{ Company.scoped }

        Apartment.configure do |config|
          config.excluded_models = []
          config.database_names = dbs
        end

        Apartment.database_names.should == Company.scoped
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
apartment-0.18.0 spec/unit/config_spec.rb
apartment-0.17.3 spec/unit/config_spec.rb
apartment-0.17.2 spec/unit/config_spec.rb
apartment-0.17.1 spec/unit/config_spec.rb
apartment-0.17.0 spec/unit/config_spec.rb
apartment-0.16.0 spec/unit/config_spec.rb