Project

poof

0.0
No commit activity in last 3 years
No release in over 3 years
An alternative to DatabaseCleaner for automatically ensuring that objects created during tests are removed from the database.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.0
~> 10.3
~> 3.2
~> 0.10
~> 0.8

Runtime

>= 4.1.5, ~> 4.1
 Project Readme

Circle CI

poof

poof Ruby Gem - a gem for cleaning up test ActiveRecord instances

usage

Add the following to your spec_helper.rb (or wherever you setup your RSpec examples)

require 'poof'

RSpec.configure do |conf|
    conf.include Poof::Syntax
end

Then in your example

describe 'speed limit' do

    before(:all) { Poof.start }

    after(:all) { Poof.end }

    subject { road.speed_limit }

    context 'when on the highway' do

        let(:road) { poof! create(:road_factory, type: :highway) }

        it 'is 55 mph' do
            expect(subject).to eq 55
        end
    end

    context 'when near children' do

        let(:road) { poof! create(:road_factory, type: :school_road) }

        it 'is 25 mph' do
            expect(subject).to eq 25
        end
    end
end

That's it, the records created for the test will be cleaned up for you automatically.