Checking errors in functional tests?

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 10, 2005, at 8:12 AM, Rick B. wrote:

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-----

@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