amatsuda / database_rewinder

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

handle sqlite3 absolute path in config. #3

Closed shioyama closed 11 years ago

shioyama commented 11 years ago

I figured out the main reason my specs were failing when I replaced cleaner with rewinder: the sqlite3 adapter changes the relative path of the db file in config/database.yml to an absolute path, so c.db == database evaluates to false in record_inserted_table.

Here's the relevant line in activerecord:

https://github.com/rails/rails/blob/f13b278568a1d629dd4d90b16ed87b715c4e689d/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L21

I've added a few lines to compare absolute paths in the case where the adapter is sqlite3 and we're not using :memory:, and a spec that checks this. Maybe there's a cleaner way to do this, but anyway this works.

amatsuda commented 11 years ago

:cool::sparkles: