Sha256: 3bcc2236b58f01993c95a3b094e7a45fbad99e545cd5642b6a6b496ab9053ff9

Contents?: true

Size: 1.31 KB

Versions: 39

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal = true

RSpec.describe :apply_migration do
  link :apply_migration, from: :ree_migrator
  link :create_migrations_table, from: :ree_migrator

  before do
    Ree.enable_irb_mode
    require_relative('../../db')

    db = ReeMigratorTest::Db.new

    db.tables.each do |table|
      db.drop_table(table)
    end

    create_migrations_table(db)
  end

  after do
    Ree.disable_irb_mode
  end

  it {
    db = ReeMigratorTest::Db.new

    apply_migration(
      db,
      File.expand_path(
        File.join(__dir__, '../../sample_migrations/schema_migrations/create_test_table.rb')
      ),
      :schema
    )

    apply_migration(
      db,
      File.expand_path(
        File.join(__dir__, '../../sample_migrations/data_migrations/populate_test_table.rb')
      ),
      :data
    )

    migrations = db[:migrations].order(:id).all
    migration = migrations.first

    expect(migration[:id]).to be_a(Integer)
    expect(migration[:filename]).to eq("create_test_table.rb")
    expect(migration[:created_at]).to be_a(DateTime)
    expect(migration[:type]).to eq('schema')

    migration = migrations.last

    expect(migration[:id]).to be_a(Integer)
    expect(migration[:filename]).to eq("populate_test_table.rb")
    expect(migration[:created_at]).to be_a(DateTime)
    expect(migration[:type]).to eq('data')
  }
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ree_lib-1.0.39 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_migrator/spec/ree_migrator/functions/apply_migration_spec.rb