gpt4 book ai didi

ruby-on-rails - 对 http header 进行集成测试的弃用警告

转载 作者:行者123 更新时间:2023-11-28 21:27:42 26 4
gpt4 key购买 nike

我正在使用 MiniTest 并且在集成测试中有一行:

assert_select response.header['Content-Type'], "application/json"

然而它的回应是:

DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected ';' after '[#Nokogiri::CSS::Node:0x000000064b2e58 @type=:CHILD_SELECTOR, @value=[#Nokogiri::CSS::Node:0x000000064b3268 @type=:ELEMENT_NAME, @value=["application"]>, #Nokogiri::CSS::Node:0x000000064b2ef8 @type=:ELEMENT_NAME, @value=["json"]>]>]' (called from block in class:SessionsTest> at (byebug):1)

有人知道这是什么原因以及如何(或者)测试 header 吗?

最佳答案

assert_select用于检查 DOM 对象中的期望,通常是 View 结果。

在您的案例中,您可能应该使用的是 assert_equal。另请注意,在 assert_equal 中,期望值是第一个参数。

assert_equal "application/json", response.header['Content-Type']

关于ruby-on-rails - 对 http header 进行集成测试的弃用警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34977768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com