Sit back, relax, and enjoy the code.

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: , | Comments Off

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/Bookmark