On 2 December 2016 at 16:57, 'krfg' via Ruby on Rails: Talk <rubyonrails-talk@googlegroups.com> wrote: > Some of my tests would not pass if the test database was not cleared after > the previous tests. > For instance my application, based on the Michael Hartl's tutorial, gives > users the opportunity to create an association between two users. > The web interface is configured to use or not use Ajax. > There are usually two tests, one for Ajax and the other for standard html > requests, and both of them check that the association between the same two > users user1 and user2 was created by counting the number of user1 > relationships, that should be increased by 1. Now user1 could not create > twice the same association with user2, unless that association was cleared > after the first test. Is that so? > If this is Rails behaviour, which I only guess is such because I could not > find documentation about it, I would rely on this for all my future tests. > In particular I would like to test a background job that populates my > database by counting that the number of saved records (100) is correct as > expected. > If the database is cleared after this test I could re run the test and I > would still count 100 records. > If the database is not cleared, the second time I run the test I would count > 200 records, so the test would fail.
The default is that the database will be rolled back between tests. If you look in test.log you will the rollbacks happening. Colin > > -- > 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/8ad94737-79e0-46d7-ba7c-a616b3e4dc08%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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/CAL%3D0gLu7cZfyL50zzRSL1Hwq3RBc5ej9MKsvrVVN4%2BEqR%2BOZWw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.