Sha256: b14eb43634e526bf27da5015ac91b11fa1b3342fb316c4c72994d70a4aae59c7

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 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
    @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.0.0 spec/features/migration_spec.rb
sql_migrations-1.1.0 spec/features/migration_spec.rb