# Model test

**URL:** <https://www.ruby-forum.com/t/model-test/161035>\
**Category:** Rails\
**Created:** [February 22, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/model-test/161035 "2009-02-22T18:16:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arshak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@arshak](https://www.ruby-forum.com/u/arshak)\
**Post date:** [February 22, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/model-test/161035/1 "2009-02-22T18:16:06Z")

</div>

Hello,

I have a before\_validation\_on\_create callback on one of my models. It  
works fine when I run it through the console in dev/prod but in test  
(also going against mysql) it doesn’t seem to fire.

Anything special about rake test and callbacks?

Thanks,

Arshak

---

<div class="post-metadata">

**Author:** ![arshak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@arshak](https://www.ruby-forum.com/u/arshak)\
**Post date:** [February 22, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/model-test/161035/2 "2009-02-22T19:30:59Z")

</div>

Arshak N. wrote:

> Hello,
> 
> I have a before\_validation\_on\_create callback on one of my models. It  
> works fine when I run it through the console in dev/prod but in test  
> (also going against mysql) it doesn’t seem to fire.

Post your test code. It should raise an exception on create! , and  
should return  
nil on create(). So if you miss either of those, the validation appears  
to not work.
