amatsuda / database_rewinder

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

Enable `.clean_with` to receive simple arguments #18

Open deeeki opened 10 years ago

deeeki commented 10 years ago

This change enables the method to receive as the following

DatabaseRewinder.clean_with except: ["foos"]

while keeping compatibility.

DatabaseRewinder.clean_with :truncation, except: ["foos"]

for DatabaseRewinder first-choice users :dash:

amatsuda commented 10 years ago

Well, thanks, but I'm not really a fan of clean_with only: ['foos'] syntax.

Actually I was also thinking of solving that API issue, and my take was like this: https://github.com/amatsuda/database_rewinder/compare/compat

You see the main code looks totally simple and beautiful by putting these :poop:s away, but I guess we need another handy interface for configuring :except and :only before pushing them to the origin. Thoughts?

deeeki commented 10 years ago

Thanks for your comment. Yeah, separating modules looks fine.

I think the simplest way is;

DatabaseRewinder.only = ['foos'] # and also set to cleaners

in most cases it will work good. But in case of changing options in a particular test, users have to take care of current @except value (kept or overwritten, also have to set empty @except depending on DBR's spec).

so another ides is;

DatabaseRewinder.cleaner_options = only: ['foos'], except: []

this is kinda verbose but flexible and users can always write with just 1 line.