Before(:all) leaves records in database

Hi,

When I test my Rails controller, I find that records created in
before(:all) remain in database while records created in before(:each)
and let are wiped out after testing. This made me run “rake
test:prepare” for every new test. Is that normal?

Best regards,
Zhi-Qiang L.
[email protected]

Yes,

Only before :each is run in transaction. You should avoid creating
records in the before :all hook

On Nov 25, 2011, at 8:04 AM, Zhi-Qiang L. wrote:

Hi,

When I test my Rails controller, I find that records created in before(:all)
remain in database while records created in before(:each) and let are wiped out
after testing. This made me run “rake test:prepare” for every new test. Is that
normal?

Yes. before(:all) is not run in a transaction.