我正在阅读 RailsTutorial,但我被困在第 9.3 章。当我尝试在 9.3 结束时运行套件测试时,Rspec 不断给我这些错误:
/Users/shaan/Sites/sample_app/spec/support/utilities.rb:15:in `sign_in': undefined local variable or method `signin_path' for #<Class:0x107759358> (NameError)
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.3/lib/active_record/validations.rb:56:in `save!': Validation failed: Email has already been taken (ActiveRecord::RecordInvalid)
首先我得到了最大的错误,然后再次运行了很多次测试,我不断地得到第二个错误。
以下是我的控制器路由和测试文件:
- 控制器: http: //pastebin.com/vJdCxthQ
- 测试: http: //pastebin.com/SEVLd9Gg
- 路线: http: //pastebin.com/7LjA5Any
实用程序.rb:
include ApplicationHelper
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
def sign_in(user)
visit signin_path
fill_in "Email", :with => user.email
fill_in "Password", :with => user.password
click_button "Sign in"
# Sign in when not using Capybara as well.
cookies[:remember_token] = user.remember_token
end
知道我做错了什么吗?