2nd arg to should[_not] should be constrained to a String #142

dchelimsky opened this Issue Apr 24, 2012 · 3 comments


None yet

3 participants


obj.should matcher, :something_other_than => "A String" should raise an error saying a String is required.

mcbsys commented Apr 24, 2012

This will help to avoid subtle syntax errors in tests. For example:

it { should have_link(new_email), :href => users_path(new_user) }

currently succeeds silently regardless of the value of href. The problem here is that :href => users_path(new_user) is inadvertently passed to the should as a message param instead of being passed to the have_link matcher. Because message currently is not restricted to the String type, the test does not raise a syntax error, and the test passes no matter what href is in the link. Here is the correct syntax for that test:

it { should have_link(new_email, :href => users_path(new_user)) }


With #173 merged can this be closed?



@dchelimsky dchelimsky closed this Oct 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment