Sha256: 81e8b1507b8545169de3e38494e88b326dccf27bbc0997f55c2b0c8fa3f0fd69

Contents?: true

Size: 1.89 KB

Versions: 12

Compression:

Stored size: 1.89 KB

Contents

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when database and definition are same (default unsigned / nothing -> unsigned:false)' do
    let(:actual_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id",                 null: false
        end
      RUBY
    }

    let(:expected_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id", unsigned: false,null: false
        end
      RUBY
    }

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

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_false
      expect(subject.dump).to eq actual_dsl.undent.strip
      delta.migrate
      expect(subject.dump).to eq expected_dsl.undent.strip.gsub('unsigned: false,', '                ')
    }
  end

  context 'when database and definition are same (default null / unsigned:false -> nothing)' do
    let(:actual_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id", unsigned: false,null: false
        end
      RUBY
    }

    let(:expected_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id",                 null: false
        end
      RUBY
    }

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

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_false
      expect(subject.dump).to eq actual_dsl.undent.strip.gsub('unsigned: false,', '                ')
      delta.migrate
      expect(subject.dump).to eq expected_dsl.undent.strip
    }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ridgepole-0.2.2 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.2.1 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.2.0 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.9 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.8 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.7 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.6 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.5 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.4 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.3 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.2 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.1.1 spec/migrate/migrate_same_default_unsigned_spec.rb