测试 Flash 消息的内容:`The assertion was not 运行 because of an invalid css selector`
Testing the content of a flash message: `The assertion was not run because of an invalid css selector`
我想测试一下 flash 消息是否包含特定文本。所以我有这条线:
assert_select flash[:info], "Your fee is valid till"
但是失败并显示错误消息:
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '#' after ''
有人明白我做错了什么吗?
仅用于测试您不需要的消息assert_select
。只有 assert
可以。
如果你想测试打印的 HTML 然后使用 assert_select
。 assert_select
的第一个参数是 HTML 选择器,例如 div
.
试试这个。
assert_equal "Your fee is valid till", flash[:info]
或
assert_select 'div.alert-info', flash[:info]
我想测试一下 flash 消息是否包含特定文本。所以我有这条线:
assert_select flash[:info], "Your fee is valid till"
但是失败并显示错误消息:
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '#' after ''
有人明白我做错了什么吗?
仅用于测试您不需要的消息assert_select
。只有 assert
可以。
如果你想测试打印的 HTML 然后使用 assert_select
。 assert_select
的第一个参数是 HTML 选择器,例如 div
.
试试这个。
assert_equal "Your fee is valid till", flash[:info]
或
assert_select 'div.alert-info', flash[:info]