Sha256: 2c850a5c394210cea54386d70d4bde7c18935d5791bd1b39190e922a06e9c3c8

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when create table with ignore:true' do
    let(:dsl) do
      erbh(<<-ERB)
        create_table "departments", primary_key: "dept_no", force: :cascade do |t|
          t.string "dept_name", limit: 40, null: false
          t.index ["dept_name"], name: "dept_name", unique: true
        end

        create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
          t.integer "emp_no", null: false
          t.string  "dept_no", null: false
          t.date    "from_date", null: false, ignore: true
          t.date    "to_date", null: false
          t.index ["dept_no"], name: "dept_no", ignore: true
          t.index ["emp_no"], name: "emp_no"
        end
      ERB
    end

    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "departments", primary_key: "dept_no", force: :cascade do |t|
          t.string "dept_name", limit: 40, null: false
          t.index ["dept_name"], name: "dept_name", unique: true
        end
      ERB
    end

    let(:expected_dsl) { dsl.each_line.reject { |l| l =~ /ignore/ }.join }

    before { subject.diff(actual_dsl).migrate }
    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_ruby actual_dsl
      delta.migrate
      expect(subject.dump).to match_ruby expected_dsl
    }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ridgepole-0.9.5 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.4 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.3 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.2 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.1 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.0 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb
ridgepole-0.9.0.rc1 spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb