Sha256: 5a2e8de13013e09668e2acbe0598c60ff981c72a958994d6441d1e1a8ae80af4

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
describe ConnectionManager::ConnectionBuilder do

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
connection_manager-0.3.10 spec/lib/connection_builder_spec.rb
connection_manager-0.3.9 spec/lib/connection_builder_spec.rb
connection_manager-0.3.8 spec/lib/connection_builder_spec.rb
connection_manager-0.3.7 spec/lib/connection_builder_spec.rb
connection_manager-0.3.6 spec/lib/connection_builder_spec.rb
connection_manager-0.3.5 spec/lib/connection_builder_spec.rb
connection_manager-0.3.4 spec/lib/connection_builder_spec.rb
connection_manager-0.3.3 spec/lib/connection_builder_spec.rb
connection_manager-0.3.2 spec/lib/connection_builder_spec.rb
connection_manager-0.3.1 spec/lib/connection_builder_spec.rb
connection_manager-0.3.0 spec/lib/connection_builder_spec.rb