簡體   English   中英

邁克爾·哈爾 (Micheal Harl) 的 Ruby on Rails 清單 8.7 中的 assert_template 是什么意思

[英]What does the assert_template mean in Micheal Harl's Ruby on Rails listing 8.7

在 Micheal Harl 的 Ruby on Rails 教程第 6 章中,下面清單 8.7 中的測試代碼讓我有點困惑:

require 'test_helper'

class UsersLoginTest < ActionDispatch::IntegrationTest

  test 'login with invalid information' do
    get login_path
    assert_template 'sessions/new'
    post login_path, session: { email: "", password: "" }
    assert_template 'sessions/new'
    assert_not flash.empty?
    get root_path
    assert flash.empty?
  end
end

上面的代碼是為了捕捉一個不需要的 flash 錯誤消息持久性問題,但我不太確定assert_template來自哪里。

有人可以解釋上面的代碼嗎?

Rails API 文檔

斷言請求是使用適當的模板文件或部分呈現的。

對於上面每一行的文檔,我真的建議你單獨用谷歌搜索每一行(谷歌上的“assert_template rails”之類的東西就可以完成這項工作)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM