首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >考试在8.20栏考试中没有通过

考试在8.20栏考试中没有通过
EN

Stack Overflow用户
提问于 2015-09-02 17:46:17
回答 1查看 116关注 0票数 0

失败“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

代码语言:javascript
复制
    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
end

User.yml

代码语言:javascript
复制
michael: 
  name: michael 
  email: michael@example.com
  password_digest: <%= User.digest("password") %>
EN

回答 1

Stack Overflow用户

发布于 2015-09-03 01:03:34

我会再次检查您的头模板,并确认“配置文件”链接(清单8.16)有适当的代码,因为出现了测试失败的地方。

我对Rails并不十分了解,但这部分错误让我有点担心:matching "a[href="/users.762146111"]"。我希望那是/users/762…

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32359876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档