Sha256: c81d3c79bb89e90956bbcf719f6c1587e1f6b97ff6e789b39778dcc3189c9189

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

describe 'no loadable configuration file' do
  it 'should raise error when config is not loaded' do
    expect { SqlMigrations.scripts }.to raise_error RuntimeError
  end
end

describe 'loadable configuration file' do
  before do
    File.open('databases.yml', 'w') do |f|
      f.puts 'development:'
      f.puts '  databases:'
      f.puts '    default:'
      f.puts '      adapter: sqlite3'
      f.puts '      database: <%= ENV["DB_NAME"] %>'
      f.puts '  options:'
      f.puts '    separator: ;'
    end
    ENV['DB_NAME'] = 'test_database'
    SqlMigrations::Config.load! 'databases.yml'
  end

  it 'should use environment variables in config' do
    databases = SqlMigrations::Config.databases
    expect(databases[:default][:database]).to eq 'test_database'
  end

  it 'should parse database correctly' do
    databases = SqlMigrations::Config.databases[:default]
    expect(databases).to eq(adapter: 'sqlite3', database: 'test_database')
  end

  it 'should parse options correctly' do
    options = SqlMigrations::Config.options
    expect(options[:separator]).to eq ';'
  end

  after do
    ENV.delete('DB_NAME')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sql_migrations-2.6.1 spec/features/config_spec.rb
sql_migrations-2.6.0 spec/features/config_spec.rb
sql_migrations-2.5.0 spec/features/config_spec.rb
sql_migrations-2.4.0 spec/features/config_spec.rb