[rspec-users] Example for attr_accessible?

Steve vertebrate at gmail.com
Mon Oct 15 22:35:48 EDT 2007

Is anyone out there writing specs to check attr_accessible fields? I had
originally written my spec to check for allowing the desired fields, and
then none of the other regular db fields. Unfortunately this isn't
satisfactory, because attr_protected could have been used instead, which
of course wouldn't prevent mass assignment to any whatever=(val) method.

I'm thinking of maybe some internal Rails variable that holds an array of
accessible fields maybe? Does anyone know if such a thing exists? Just to
make it clear, I don't want to test Rails, I want to check that the
accessible fields have been set properly. Would it be possible to mock or
some such to check for a call to attr_accessible?


More information about the rspec-users mailing list