Sha256: 745d12fb823c36c472d35573ab7c6b60e2759c5fde7fe7ea7b00819fd7761ab2

Contents?: true

Size: 922 Bytes

Versions: 3

Compression:

Stored size: 922 Bytes

Contents

require 'spec_helper'

describe Database do
  
  let(:root) { `pwd`.sub(/\n/, '') }
  let(:db) { Database.new(root) }

  describe '#load' do
  
    context 'loading config/database.yml from rails app' do

      it 'should call join on file for yaml retreival' do
        File.should_receive(:join)
        YAML.should_receive(:load_file)
        Database.any_instance.should_receive(:connect)
        db.load
      end 

    end

  end

  describe '#connect' do

    context 'establishing connection' do

      it 'should call establish connection on active record with proper args' do
        file = File.join(root, 'spec', 'database.yml')
        yaml = YAML.load_file(file)
        ActiveRecord::Base.should_receive(:establish_connection)
          .with({:adapter=>"mysql2", :database=>yaml['development']['database']})
        Generator.stub(:create_factories)
        db.connect(yaml)
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
industrial_girl-0.0.3 spec/database.spec
industrial_girl-0.0.2 spec/database.spec
industrial_girl-0.0.1 spec/database.spec