Using assert_select to find an attribute that has square brackets in the value
Posted: March 1st, 2009 | Author: gabe | Filed under: Rails, Testing | Tags: assert_select, invalid selector | Comments OffProblem: assert_select 'input[name=model_name[field_name]]' gives ArgumentError: Invalid selector: ]
Solution: assert_select 'input[name=?]', 'model_name[field_name]'
Thanks to the Boston Ruby Group thread for the answer.
Bonus: Here’s a helpful assert_select cheat sheet.