简体   繁体   中英

Ruby on Rails Tutorial chapter 9.3.3

I have tried to do chapter 9.3.3 in Ruby on Rails Tutorial (http://railstutorial.org).

Whenever I run the tests it say something along the lines of:

Failures:

  1) Users sign in/out success should sign a user in and out
     Failure/Error: user = Factory(:user)
     ActiveRecord::RecordInvalid:
       Validation failed: Email has already been taken
     # ./spec/requests/users_spec.rb:53:in `block (4 levels) in <top (required)>'

Finished in 5.8 seconds
4 examples, 1 failure

I've tried various fixes including resetting the database - both using rake db:reset and rake db:populate.

I would appreciate any help.

Thanks in advance.

It seems that your test database is not wrapped around a transaction while your tests are running. This is causing you test database to persist between test runs. Use database cleaner to clean up your test database after each spec is run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM