On 10/15/07, Steve <[EMAIL PROTECTED]> wrote: > 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? > > Thanks, > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
You could expect a call to attr_accessible and then load your model file. Or, loop through all the column names in your model, and make sure that only the ones that are supposed to be accessible get set. Pat _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users