amatsuda / database_rewinder

minimalist's tiny and ultra-fast database cleaner
MIT License
807 stars 91 forks source link

Add cleaning method #36

Closed sachin21 closed 8 years ago

sachin21 commented 8 years ago

This pull request is a feature implement. I added clearing method. The reason for the added is simple. database_cleaner have a cleaning method. so We have to make DatabaseRewinder be compatible with DatabaseCleaner. because DatabaseCleaner class should be replaceable to DatabaseRewinder. FYI

So I added claering method, wrote a test for clearing method and I tested on my product.

Testing

My DatabaseRewinder's configurations is

RSpec.configure do |config|
  config.before(:suite) do
    DatabaseRewinder.clean_with(:truncation, except: %w(languages))
    DatabaseRewinder.strategy = :transaction
  end

  config.around(:each) do |example|
    DatabaseRewinder.cleaning do
      example.run
    end
  end
end

So I executed rspec spec on my product then output this:

screenshot 2016-04-14 22 52 19

👯 It was successfully executed.

deeeki commented 8 years ago

Thanks for your PR 😃

I think this can be implemented with less codes. And you should use DatabaseRewinder::Compatibility module.

P.S. cleaning instead of clearing in your commit message and PR title.

sachin21 commented 8 years ago

@deeeki Thank you for the review! I fixed it. 😄 Could you re-review my changes?

deeeki commented 8 years ago

Good 👍 Thank you!

sachin21 commented 8 years ago

Thank you, too!