The opposite of assert_select?

后端 未结 4 781
天涯浪人
天涯浪人 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:22

    You can easily define your own:

    module ActionDispatch::Assertions::SelectorAssertions
      def refute_select(*a,&b)
        begin
          assert_select(*a,&b)
        rescue AssertionFailedError
          return
        end
        raise "fail" # there should be a better built-in alternative
      end
    end
    

提交回复
热议问题