Using assert_select to find an attribute that has square brackets in the value

Problem: 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.

Share
This entry was posted in Rails, Testing and tagged , . Bookmark the permalink.

Comments are closed.