# Checking errors in functional tests?

**URL:** <https://www.ruby-forum.com/t/checking-errors-in-functional-tests/47632>\
**Category:** Rails\
**Created:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/checking-errors-in-functional-tests/47632 "2005-11-12T12:49:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@rick](https://www.ruby-forum.com/u/rick)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/checking-errors-in-functional-tests/47632/1 "2005-11-12T12:49:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@rick](https://www.ruby-forum.com/u/rick)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/checking-errors-in-functional-tests/47632/2 "2005-11-12T12:49:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@rick](https://www.ruby-forum.com/u/rick)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/checking-errors-in-functional-tests/47632/3 "2005-11-12T12:49:51Z")

</div>

- Jeremy K. (removed\_email\_address@domain.invalid) [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
