Sha256: 81c16b23bc767e173c5da90863b6958b502ce34840f6f647b230beb50ef4fb86

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'
describe ConnectionManager::Builder do

  describe '#connection_class_name' do 
    it "should return a string for a class name appended with 'Connection' " do
      expect(ConnectionManager::Builder.send(:connection_class_name,"my_database")).to eql("MyDatabaseConnection")
    end
    it "should return remove the appended rails env" do
      expect(ConnectionManager::Builder.send(:connection_class_name,"my_database_test")).to eql("MyDatabaseConnection")
    end
    it "should use the database name from the database.yml if supplied string is only is only the Rails.env" do
      expect(ConnectionManager::Builder.send(:connection_class_name,"test")).to eql("BaseConnection")
    end
  end
    
  describe '#build_connection_class' do
    before(:all) do
      ConnectionManager::Builder.build_connection_class("MyConnectionClass", :test)
    end
    it "should add a class with supplied class name to ConnectionManager::Builder" do
      expect(defined?(MyConnectionClass)).to be_true
      expect(MyConnectionClass).to be_a(Class)
    end
    it "should have a super class of ActiveRecord::Base" do
     expect(MyConnectionClass.superclass).to eql(ActiveRecord::Base)
    end
    it "should be an abstract class" do
      expect(MyConnectionClass.abstract_class?).to be_true
    end
  end   
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
connection_manager-1.1.5 spec/lib/builder_spec.rb
connection_manager-1.1.4 spec/lib/builder_spec.rb
connection_manager-1.1.3 spec/lib/builder_spec.rb
connection_manager-1.1.2 spec/lib/builder_spec.rb
connection_manager-1.1.1 spec/lib/builder_spec.rb
connection_manager-1.1.0 spec/lib/builder_spec.rb