Project

phenix

0.01
Low commit activity in last 3 years
A long-lived project that still receives updates
Read a dynamic database.yml file and allow you to drop/create the database on demand.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 12.3.3
~> 3.4

Runtime

>= 4.2, < 7.2
 Project Readme

Phenix

Helps you spawn ActiveRecord databases at the beginning of your tests and destroying them when you're done. Handles database configuration with YAML. Only works for mysql at the moment.

Installation

Add this line to your application's Gemfile:

gem 'phenix'

And then execute:

$ bundle

Or install it yourself as:

$ gem install phenix

Usage

  # helper.rb
  Phenix.configure do |config| # do not pass any block if you just want the defaults
    config.database_config_path = '/my/path/database.yml' # defaults to 'test/database.yml'
    config.schema_path          = 'my/path/schema.rb'     # defaults to 'test/schema.rb'

    config.skip_database = ->(name, conf) { name =~ /do_not_create/ } # define this lambda if you want to skip the creation of some databases
  end

  # in your test file
  before do
    Phenix.rise! # pass with_schema: false if you don't want the schema loaded
  end

  after do
    Phenix.burn!
  end

How do I run tests?

bundle exec rspec This will assume that your DB is accessible via localhost for root with no password. For a different configuration, you can use the MYSQL_URL environment variable (see test/complex_database.yml).

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/zendesk/phenix.