Sha256: 325c62671df8c59cd81bec8cdb094dd9a16159fe0391614c2c2d5596a6eef39f

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_relative '../integration_helper'

describe 'Deleting a migration' do
  subject { MinceMigrator::Deleter.new(name: name) }

  let(:name) { 'name of migration' }
  let(:expected_name) { 'Name of migration' }

  context 'when the migration exists' do
    before do
      MinceMigrator::Creator.create(name)
    end

    its(:can_delete_migration?) { should be_true }

    it 'deletes it from the file system' do
      expected_migration_destination = ::File.join(MinceMigrator::Config.migration_dir, 'name_of_migration.rb')
      subject.delete_migration

      ::File.exists?(expected_migration_destination).should be_false
    end

    context 'when the migration has ran' do
      before do
        MinceMigrator::Migrations::Runner.new(name: name).run_migration
      end

      it 'deletes it from the database' do
        subject.delete_migration

        MinceMigrator::RanMigration.all.should be_empty
      end
    end
  end

  context 'when the migration does not exist' do
    its(:can_delete_migration?) { should be_false }
    its(:reasons_for_failure) { should == "Migration does not exist with name '#{expected_name}'" }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mince_migrator-1.0.2 spec/integration/deleting_a_migration_spec.rb
mince_migrator-1.0.1 spec/integration/deleting_a_migration_spec.rb
mince_migrator-1.0.0 spec/integration/deleting_a_migration_spec.rb