简体   繁体   English

Ruby on Rails教程第9.3.3节

[英]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). 我曾尝试在Ruby on Rails教程(http://railstutorial.org)中进行9.3.3节。

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. 我尝试了各种修复,包括重置数据库 - 使用rake db:reset和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. 运行每个规范后,使用数据库清理程序清理测试数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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