Sha256: 97d12a05022af1045a3d0c41ff97fe1cb6d2a0fe30a251b3120f23255e7f4880

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

describe 'migration' do
  before do
    Dir.mkdir('/migrations')
    File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
      f.puts "CREATE TABLE test_table(col_int INTEGER, col_str STRING)"
    end
    allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
    @migration = SqlMigrations::Migration.find([ :default ]).first
  end

  it 'should be found and initialized' do
    expect(@migration).to be_a(SqlMigrations::Migration)
  end

  it 'should have proper date' do
    expect(@migration.date).to eql('20150305')
  end

  it 'should have proper time' do
    expect(@migration.time).to eql('154010')
  end

  it 'should have proper name' do
    expect(@migration.name).to eql('test_migration')
  end

  it 'should be properly executed' do
    $stdout = StringIO.new
    database = SqlMigrations::Database.new(name: :default, 'adapter' => :sqlite)
    @migration.execute(database)
    expect(@sqlite_db.table_exists?(:test_table)).to be true
    expect(@sqlite_db[:test_table].columns).to include(:col_int)
    expect(@sqlite_db[:test_table].columns).to include(:col_str)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sql_migrations-2.1.0.pre2 spec/features/migration_spec.rb
sql_migrations-2.1.0.pre1 spec/features/migration_spec.rb