Q:

how to clean database before running the each spec file?

I want to clear my test database before running the each spec files. 
I am already using rspec with factory girl. 
Thanks,
Hare 

A:

Add to RSpec.configure block in your spec_helper.rb
  config.before(:suite) do
    DatabaseCleaner.clean_with :truncation
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

Must work

