Sha256: fec1b9297bcb7d621039c1789e0c29f2509612968da8a293da575efb88708298

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

describe 'Ridgepole::Client#diff -> migrate' do
  before { subject.diff(actual_dsl).migrate }
  subject { client(:table_options => table_options, :dump_without_table_options => dump_without_table_options) }

  let(:warning_regexp) { /table options differ/ }
  let(:dump_without_table_options) { false }

  let(:actual_dsl) {
    erbh(<<-EOS)
      create_table "employees", primary_key: "emp_no", force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
      end
    EOS
  }

  let(:expected_dsl) {
    erbh(<<-EOS)
      create_table :employees, primary_key: :emp_no, force: :cascade do |t|
      end
    EOS
  }

  context 'when change options (no change)' do
    let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8' }

    it {
      expect(Ridgepole::Logger.instance).to_not receive(:warn).with(warning_regexp)
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end

  context 'when change options (change)' do
    let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }

    it {
      expect(Ridgepole::Logger.instance).to receive(:warn).with(warning_regexp)
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end

  context 'when dump_without_table_options => true' do
    let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }
    let(:dump_without_table_options) { true }

    it {
      expect(Ridgepole::Logger.instance).to_not receive(:warn)
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ridgepole-0.7.3.beta spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.2 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.2.beta spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1.beta5 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1.beta4 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1.beta3 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1.beta2 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.1.beta spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.0 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.0.rc1 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.0.beta22 spec/mysql/migrate/migrate_change_column8_spec.rb
ridgepole-0.7.0.beta21 spec/mysql/migrate/migrate_change_column8_spec.rb