我正在关注 railscast #275 测试忘记密码。我无法通过电子邮件已被采取错误。使用我按照教程进行的编码,我想收到此错误,“没有标题或文本“密码”链接的错误。相反,这是我得到的,“验证失败:电子邮件已被使用(ActiveRecord: :记录无效)"
我已经进行了搜索,无法找到解决方案。
这是password_resets_spec.rb:
require 'spec_helper'
describe "PasswordResets" do
it "emails user when requesting password reset"
user = FactoryGirl.create(:user)
visit login_path
click_link "password"
fill_in "Email", :with => user.email
click_button "Reset Password"
end
工厂.rb:
FactoryGirl.define do
factory :user do
sequence :email do |n| "test#{n}@example.com"
end
password "secret"
end
end