Coder Social home page Coder Social logo

database_rewinder's Introduction

DatabaseRewinder

database_rewinder is a minimalist's tiny and ultra-fast database cleaner.

Features

  • Cleans up tables via DELETE SQL. No other strategies are implemented ATM
  • Supports multiple databases
  • Runs extremely fast ๐Ÿ’จ

Why is it fast?

database_rewinder memorizes every table name into which INSERT SQL was performed during each test case. Then it executes DELETE SQL only against these tables when cleaning. So, the more number of tables you have in your database, the more benefit you will get.

Credit

This strategy was originally devised and implemented by @eudoxa.

Supported versions

  • ActiveRecord 3.2, 4.0, 4.1

  • Ruby 2.0, 2.1

Installation

Add this line to your Gemfile's :test group:

gem 'database_rewinder'

And then execute:

$ bundle

Usage

Do clean in after(:each). And do clean_all or clean_with in before(:suite) if you'd like to.

RSpec.configure do |config|
  config.before :suite do
    DatabaseRewinder.clean_all
    # or
    # DatabaseRewinder.clean_with :any_arg_that_would_be_actually_ignored_anyway
  end

  config.after :each do
    DatabaseRewinder.clean
  end
end

Pro Tip

database_rewinder is designed to be almost compatible with database_cleaner. So the following code will probably let your existing app work under database_rewinder without making any change on your configuration.

DatabaseCleaner = DatabaseRewinder

Contributing

Send me your pull requests.

database_rewinder's People

Contributors

amatsuda avatar fgo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.