On Fri, Dec 2, 2016 at 12:56 PM, 'krfg' via Ruby on Rails: Talk
<rubyonrails-talk@googlegroups.com> wrote:
> On Friday, December 2, 2016 at 6:45:12 PM UTC+1, Dave Aronson wrote:
>>
>> The important thing is that every test start from a *known state*.
>> The easiest state to achieve and reason about, is empty.
>
> And what is Rails' default behaviour?
> I only guess that it empties all tables after each test, but this is only my
> guess.

I'm not sure but I think it rolls back changes (i.e., the transaction
each test is wrapped in) after each test.  Or that may be dependent on
what db and/or test framework you're using; I don't think it's even
possible with SQLite, but I usually use PostgreSQL.  Anyway, I've
usually used the database-cleaner gem
(https://github.com/DatabaseCleaner/database_cleaner) rather than rely
on whatever Rails chooses to do.  Check it out; there may be a
configuration that meets your needs.  Avdi Grimm also wrote a good
blog post on it long ago that I remember finding very helpful.

-Dave

-- 
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQijbdef1iwMoiD5wqZJENkXptCzj5YyatOLC9gv%3Dags-CA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to