失败“test_test_login_with_valid_information”,UsersLoginTest,2015-08-27 20:00:02 +0000 test_test_login_with_valid_information(1440705602.54 s),预期至少有一个元素匹配“ahref=”/users.762146111,发现0.预期0为>= 1.测试/集成/users_login_test.rb:18: in‘`block in’ 2/2: ======================================================================================================= 100%时间: 00:00:00,时间: 00:00:00 在0.46825s2测试中完成,10次断言,1次失败,0次错误,0次跳转
这是user_login_test.rb
require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "test login with valid information" do
get login_path
post login_path, session: {email: @user.email, password: "password"}
assert_redirected_to @user
follow_redirect!
assert_template "users/show"
assert_select "a[href=?]", login_path, count: 0
assert_select "a[href=?]", logout_path
assert_select "a[href=?]", users_path(@user)
end
test "login with invalid information" do
get login_path
assert_template 'sessions/new'
post login_path, session: { email: "", password: "" }
assert_template 'sessions/new'
assert flash.any?
get root_path
assert flash.empty?
end
endUser.yml
michael:
name: michael
email: michael@example.com
password_digest: <%= User.digest("password") %>发布于 2015-09-03 01:03:34
我会再次检查您的头模板,并确认“配置文件”链接(清单8.16)有适当的代码,因为出现了测试失败的地方。
我对Rails并不十分了解,但这部分错误让我有点担心:matching "a[href="/users.762146111"]"。我希望那是/users/762…。
https://stackoverflow.com/questions/32359876
复制相似问题