Sha256: 67a966837ba7862c32c9b612b266e9ac1aef1f52ef1defb570684e8d0c817268

Contents?: true

Size: 1.46 KB

Versions: 15

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe 'SQL module' do
  describe 'TableModifier' do
    before do
      @adapter = mock('adapter')
      @adapter.stub!(:quote_name).and_return(%{'users'})
      @tc = SQL::TableModifier.new(@adapter, :users) { }
    end

    describe 'initialization' do
      it 'should set @adapter to the adapter' do
        @tc.instance_variable_get("@adapter").should == @adapter
      end

      it 'should set @table_name to the stringified table name' do
        @tc.instance_variable_get("@table_name").should == 'users'
      end

      it 'should set @opts to the options hash' do
        @tc.instance_variable_get("@opts").should == {}
      end

      it 'should set @statements to an empty array' do
        @tc.instance_variable_get("@statements").should == []
      end

      it 'should evaluate the given block' do
        block = proc { column :foo, :bar }
        col = mock('column')
        SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
        tc = SQL::TableCreator.new(@adapter, 'users', {}, &block)
        tc.instance_variable_get("@columns").should == [col]
      end
    end

    it 'should have a table_name' do
      @tc.should respond_to(:table_name)
      @tc.table_name.should == 'users'
    end

    it 'should use the adapter to quote the table name' do
      @adapter.should_receive(:quote_name).with('users').and_return(%{'users'})
      @tc.quoted_table_name.should == %{'users'}
    end

  end

end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
ardm-migrations-1.3.0 spec/unit/sql/table_modifier_spec.rb
ardm-migrations-1.2.1 spec/unit/sql/table_modifier_spec.rb
ardm-migrations-1.2.0 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.2.0 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.2.0.rc2 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.2.0.rc1 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.1.0 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.1.0.rc3 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.1.0.rc2 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.1.0.rc1 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.0.2 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.0.1 spec/unit/sql/table_modifier_spec.rb
dm-hibernate-migrations-1.0.0 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.0.0 spec/unit/sql/table_modifier_spec.rb
dm-migrations-1.0.0.rc3 spec/unit/sql/table_modifier_spec.rb