The opposite of assert_select?

后端 未结 4 719
天涯浪人
天涯浪人 2021-02-01 13:06

I am writing an app where it is desirable to check if a view does not have some functionality - in particular because that functionality must be presented only to users

4条回答
  •  迷失自我
    2021-02-01 13:34

    Take a look at the docs here:

    http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select

    From the docs:

    assert_select is an assertion that selects elements and makes one or more equality tests.

    and from the equality tests sections:

    The equality test may be one of the following:

    true - Assertion is true if at least one element selected.

    false - Assertion is true if no element selected.

    String/Regexp - Assertion is true if the text value of at least one element matches the string or regular expression.

    Integer - Assertion is true if exactly that number of elements are selected.

    Range - Assertion is true if the number of selected elements fit the range.

    If no equality test specified, the assertion is true if at least one element selected.

    And a simple example:

       # Page contains no forms
       assert_select "form", false, "This page must contain no forms"
    

提交回复
热议问题