为什么 assert_select 不接受参数 rails 4.2?

Why assert_select is not accepting parameters rails 4.2?

我正在进行 rails 集成测试,有人编写了当时通过的测试,但现在他们给出了警告

这是我正在处理的代码行

assert_select "a[href=/monster_xml_users/#{user_xml.id}][data-method=delete]", I18n.t('revoke_access')

但是现在是警告

Invalid CSS selector, Assertion not run

但是如果我这样写的话

 assert_select "a", I18n.t('revoke_access')
        assert_select "a" do
          assert_select "[href=?]","/monster_xml_users/#{user_xml.id}"
          assert_select "[data-method=?]", "delete"
        end

然后它没有给出任何警告并且测试通过并且它是正确的。 但我无法弄清楚为什么以前的断言现在失败了? assert_select 语法现在在 Rails 4.2 中更改了吗?

您正在遵循断言的旧语法。现在 rails 更喜欢在 css 对象周围加上引号,如下所示

assert_select "a[href='/monster_xml_users/#{user_xml.id}'][data-method='delete']", I18n.t('revoke_access')