spec/features/config_spec.rb in sql_migrations-2.1.0.pre2 vs spec/features/config_spec.rb in sql_migrations-2.1.0.pre3
- old
+ new
@@ -1,16 +1,40 @@
+describe 'no loadable configuration file' do
+ it 'should raise error when config is not loaded' do
+ expect { SqlMigrations.list_files }.to raise_error RuntimeError
+ end
+end
+
describe 'loadable configuration file' do
before do
File.open('databases.yml', 'w') do |f|
- f.puts 'default:'
- f.puts ' test:'
- f.puts ' adapter: sqlite3'
- f.puts ' database: <%= ENV["DB_NAME"] %>'
+ 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
- ENV['DB_NAME'] = 'test_database'
- SqlMigrations::Config.load! 'databases.yml'
- expect(SqlMigrations::Config.options['default']['test']['database']).to eq 'test_database'
+ 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