Flipper

"Switch your database on the fly"

Introduction

When doing integration and acceptance testing you typically need to:

  • Change and manage application state.

  • Guarantee test case isolation, even for those that change the application state.

9 times out of 10, all you need to do to achieve this for a Rails application is:

  • Have direct access to the database.

  • Ensure that tests running in parallel access a different database schema.

So if you are driving your tests at the HTTP layer (e.g. Selenium tests) you could use a single Mongrel cluster to run a lot of tests in parallel, a long as you can change your database on the fly for each HTTP requests. This is what Flipper does.

Status

The current status is quite good. Flipper is currently used on a daily basis on commercial projects.

Installation

The easiest way to install is via RubyGems. On the command line enter:

> gem install flipper

Usage

To use flipper just include the Flipper module and add a before filter in application.rb:

class ApplicationController < ActionController::Base
  include Flipper

  before_filter :switch_database

  ...
end

License

The collection PER COLLECTION is licensed as follows:

Ruby Facets
Copyright (c) 2004-2006 Thomas Sawyer

Distributed under the terms of the Ruby license.

The Ruby license is a dual license that also provides for use of the GPL. Complete texts of both licenses accompany this document (see doc/COPYING).

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Acknowledgments and Copyrights for particular snippets of borrowed code are given in their respective source. All licenses are either compatible with the Ruby license (namely the GPL) or the original author has given permission for inclusion of their code under such lincense.