Rspec testing for html entities in page content

后端 未结 4 843
我寻月下人不归
我寻月下人不归 2021-02-19 06:19

I\'m writing a request spec and would like to test for the presence of the string \"Reports » Aging Reports\". I get an error (invalid multibyte char) if I put in the character

4条回答
  •  走了就别回头了
    2021-02-19 07:08

    html_safe does not remove html tags if thats what you want.

    If you will remove html tags before you test you can use sanitize gem.

    # in Gemfile
    gem 'sanitize'
    
    # in testfile
    require 'sanitize'
    html = Sanitize.clean(page.body.text)
    html.should have_content("Reports » Aging Reports")
    

提交回复
热议问题