We''re elbow deep in functional tests and we''re trying to figure out how to do some assertions about the state of the list of validation errors on the request. We''d like to be able to assert that there are no validation errors on a successful create/update. We''d like to be able to assert that there are a specific number or matching set of errors on a failing create/update. I''ve done a lot of grovelling through the code and a lot of playing around in the breakpointer inspecting the various objects at hand and I''m not seeing how to get to this information. Anyone got any ideas on how to do this? Thanks! Rick -- http://www.rickbradley.com MUPRN: 692 | some of the desk didn''t random email haiku | receive this so I am | sending it again.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 10, 2005, at 8:12 AM, Rick Bradley wrote:> We''re elbow deep in functional tests and we''re trying to figure out > how > to do some assertions about the state of the list of validation errors > on the request. We''d like to be able to assert that there are no > validation errors on a successful create/update. We''d like to be able > to assert that there are a specific number or matching set of > errors on > a failing create/update. > > I''ve done a lot of grovelling through the code and a lot of playing > around in the breakpointer inspecting the various objects at hand and > I''m not seeing how to get to this information. > > Anyone got any ideas on how to do this?# @foo = Foo.create(invalid_params) assert !assigns(:foo).valid? assert_equal 3, assigns(:foo).errors.on(''attribute'') jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDc6F9AQHALep9HFYRAvX2AKCYbjLt77FSBooT4KesjWTmMajKWgCeMu/5 YV9Pt8yX27UuxZa6R+Ln6Ak=Y10+ -----END PGP SIGNATURE-----
* Jeremy Kemper (jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org) [051110 14:40]:> # @foo = Foo.create(invalid_params) > assert !assigns(:foo).valid? > assert_equal 3, assigns(:foo).errors.on(''attribute'')Thanks, Jeremy! Now that I''ve got the correct hook I see that I could also do something like: assertequal 1, assigns(:foo).errors.on_base.length Rick -- http://www.rickbradley.com MUPRN: 606 | A dream we don''t random email haiku | want to wake up from. This is | our wake-up call.