mercredi 9 septembre 2015

unable to assert_select in rails 4 test case

I have a string that contains html tag and some brackets. For example

mystr = "<h1>Hello(greeting message for A,B, and C). <\h1>"

i want to assert that string with a p tag.

first i remove the tag using

tag_free_string =  ActionView::Base.full_sanitizer.sanitize(mystr)

than i apply Regex escape.

final_atr = Regexp.escape (tag_free_string)

and finally assert like this

assert_select 'p.alert', /#{final_atr}/

but getting error the string contains many \\ in it.

Aucun commentaire:

Enregistrer un commentaire