Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How assert_select a string with a new line inside?

I have this string inside my html code:

1\n          \n            word

I want to make an assert_select that ignores those new lines and spaces, so I have tried this:

assert_select ".myclass", /1.+word/

But it does not work:

1) Failure: 
test_new_line(NewLineControllerTest) [test/functional/new_line_controller_test.rb:23]:
</1.+word/> expected but was
<"1\n          \n            word">.

How can I fix it?

like image 302
David Morales Avatar asked Sep 20 '25 02:09

David Morales


1 Answers

You need to specify the multiline flag since there are multiple lines in that string.

assert_select ".myclass", /1.+word/m
like image 95
vvlad Avatar answered Sep 22 '25 17:09

vvlad