http header 上集成测试的弃用警告
Deprecation warning for integration test on http header
我正在使用 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对象中的期望,一般是查看结果。
您可能应该使用的是 assert_equal
。另请注意,在 assert_equal
中,期望值是第一个参数。
assert_equal "application/json", response.header['Content-Type']
我正在使用 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对象中的期望,一般是查看结果。
您可能应该使用的是 assert_equal
。另请注意,在 assert_equal
中,期望值是第一个参数。
assert_equal "application/json", response.header['Content-Type']