Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 528
Nick Avatar asked Dec 03 '22 15:12

Nick


2 Answers

Try This.

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

OR

assert_select 'div.alert-info', flash[:info]
like image 171
Santosh Sharma Avatar answered Dec 05 '22 04:12

Santosh Sharma


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.

like image 22
Babar Al-Amin Avatar answered Dec 05 '22 04:12

Babar Al-Amin