Sha256: 276c023fb2fe0391129177ad16ad3f7f41f1cfc797f600263d1fa13b411e21c8

Contents?: true

Size: 959 Bytes

Versions: 25

Compression:

Stored size: 959 Bytes

Contents

RSpec.describe ROM::SQL::Migration::Migrator, :postgres, skip_tables: true do
  include_context 'database setup'

  subject(:migrator) { ROM::SQL::Migration::Migrator.new(conn, options) }

  let(:options) { { path: TMP_PATH.join('test/migrations') } }

  describe '#create_file' do
    it 'creates a migration file under configured path with specified version and name' do
      file_path = migrator.create_file('create_users', 1)

      expect(file_path).to eql(migrator.path.join('1_create_users.rb'))
      expect(File.exist?(file_path)).to be(true)
      expect(File.read(file_path)).to eql(migrator.migration_file_content)
    end

    it 'auto-generates version when it is not provided' do
      file_path = migrator.create_file('create_users')

      expect(file_path.to_s).to match(/.(\d+)_create_users\.rb/)
      expect(File.exist?(file_path)).to be(true)
      expect(File.read(file_path)).to eql(migrator.migration_file_content)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/unit/migrator_spec.rb
rom-sql-1.3.4 spec/unit/migrator_spec.rb
rom-sql-2.0.0.beta2 spec/unit/migrator_spec.rb
rom-sql-2.0.0.beta1 spec/unit/migrator_spec.rb
rom-sql-1.3.3 spec/unit/migrator_spec.rb
rom-sql-1.3.2 spec/unit/migrator_spec.rb
rom-sql-1.3.1 spec/unit/migrator_spec.rb
rom-sql-1.3.0 spec/unit/migrator_spec.rb
rom-sql-1.2.2 spec/unit/migrator_spec.rb
rom-sql-1.2.1 spec/unit/migrator_spec.rb
rom-sql-1.2.0 spec/unit/migrator_spec.rb
rom-sql-1.1.2 spec/unit/migrator_spec.rb
rom-sql-1.1.1 spec/unit/migrator_spec.rb
rom-sql-1.1.0 spec/unit/migrator_spec.rb
rom-sql-1.0.3 spec/unit/migrator_spec.rb
rom-sql-1.0.2 spec/unit/migrator_spec.rb
rom-sql-1.0.1 spec/unit/migrator_spec.rb
rom-sql-1.0.0 spec/unit/migrator_spec.rb
rom-sql-1.0.0.rc2 spec/unit/migrator_spec.rb
rom-sql-1.0.0.rc1 spec/unit/migrator_spec.rb