Sha256: 6bed361cd82669a1128268f7a87c7e0b9718d5fda0161e1300416d6502f66941

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

require 'flydata-core/table_def/base'

module FlydataCore
module TableDef

describe Base do
  let(:subject_object) { described_class.new(table_def, table_name, columns,
                           column_def, default_charset,
                           default_source_charset, comment) }

  let(:table_def) { double('table_def') }
  let(:table_name) { double('table_name') }
  let(:columns) { double('columns') }
  let(:column_def) { double('column_def') }
  let(:default_charset) { double('default_charset') }
  let(:default_source_charset) { double('default_source_charset') }
  let(:comment) { double('comment') }

  describe '#pk_columns' do
    subject { subject_object.pk_columns }

    let(:columns) do
      [ {column: "name"},
        {column: "address_id", primary_key: pk1_value},
        {column: "zip"},
        {column: "user_id", primary_key: pk2_value},
      ]
    end
    

    context 'with unordered primary keys' do
      let(:pk1_value) { 't' }
      let(:pk2_value) { 't' }

      it "returns primary keys in the column order" do
        is_expected.to eq %w(address_id user_id)
      end
    end
    context 'with ordered primary keys' do
      let(:pk1_value) { 2 }
      let(:pk2_value) { 1 }

      it "returns primary keys in the pk order" do
        is_expected.to eq %w(user_id address_id)
      end
    end
  end
end

end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
flydata-0.7.2.1 flydata-core/spec/table_def/base_spec.rb
flydata-0.7.2 flydata-core/spec/table_def/base_spec.rb
flydata-0.7.1 flydata-core/spec/table_def/base_spec.rb
flydata-0.7.0 flydata-core/spec/table_def/base_spec.rb
flydata-0.6.14 flydata-core/spec/table_def/base_spec.rb
flydata-0.6.13 flydata-core/spec/table_def/base_spec.rb
flydata-0.6.12 flydata-core/spec/table_def/base_spec.rb