'should_not allow_mass_assignment_of' could pass if attribute is misspelled #156

monocle opened this Issue Feb 9, 2011 · 1 comment


None yet
2 participants

monocle commented Feb 9, 2011

For example, if I have a model that's using attr_accessible,

it { should_not allow_mass_assignment_of :rememer_token }   # should be :remember_token

passes because the attribute doesn't exist. Perhaps the matcher should make sure that the subject responds to the attribute as part of the validation?


jferris commented Feb 11, 2011

This would involve extending the context framework to allow special behavior for should_not. Otherwise, not having the attribute defined would actually cause any should_not blocks to pass.

I think it's better to just combine this with tests to make sure your attributes exist. If you're willing to submit a tested patch that adds does_not_match? to the context framework and a does_not_match? method to this matcher, I'd pull it in.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment