cider-ci/shared/scripts/manage-database.yml

Summary

Maintainability
Test Coverage
configure-database:
  body: |
    #!/usr/bin/env ruby
    require 'yaml'
    config = \
      { 'test' =>
        { 'adapter' => 'postgresql',
          'encoding' => 'unicode',
          'host' => 'localhost',
          'pool' => 3,
          'username' => ENV['PGUSER'],
          'password' =>  ENV['PGPASSWORD'],
          'database' => "madek_v3_test_#{ENV['CIDER_CI_TRIAL_ID']}"}}
    File.open('config/database.yml','w') { |file| file.write config.to_yaml }

create-database:
  body: bundle exec rake db:reset
  start-when:
  - script: bundle
  - script: configure-database

delete-database:
  body:  bundle exec rake db:pg:terminate_connections db:drop
  ignore-abort: true
  ignore-state: true
  start-when:
  - script: test
    states: [aborted, passed, failed, skipped]