lakridserne
lakridserne

Reputation: 1

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.

Upvotes: 0

Views: 298

Answers (1)

Waseem
Waseem

Reputation: 8402

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.

Upvotes: 2

Related Questions