Nick Nick - 5 months ago 23
Ruby Question

Testing the content of a flash message: `The assertion was not run because of an invalid css selector`

I would like to test whether a flash message contains certain text. So I have the line:

assert_select flash[:info], "Your fee is valid till"


This however fails with the error message:

DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '#' after ''


Does anyone understand what I'm doing wrong?

Answer

Only to test the message you don't need assert_select. Only assert would do. If you wan to test printed HTML then use assert_select. First argument for assert_select is a HTML selector, like div.

Comments