[mocha-developer] ActiveRecord Validations - validates_uniqueness_of

Chris Roos chrisjroos at gmail.com
Tue Sep 12 18:02:33 EDT 2006

Good question actually.

The Person class methods will get executed during class read time
(i.e. when we first require Person).  Before double checking that, I
thought we might be able to do the following.


However, the first mention of Person parses the Person class, meaning
the expectation is not satisfied.  You can force it to re-read by
requiring relative to your test (i.e. add require
'../../app/models/person' below the expectation).

I remember James working on something that deals with exactly this
situation but I can't remember off hand what state it's in - James?


On 9/12/06, Jonathan Younger <daikini at gmail.com> wrote:
> Hello,
> I'm wanting to use Mocha and Stubba for my tests in place of the
> default Rails testing with fixtures.
> I have the following class:
> class Person < ActiveRecord::Base
>    validates_uniqueness_of :email
> end
> and am wondering how I can test to ensure that the
> validates_uniqueness_of validation is running.
> Any ideas?
> -Jonathan
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer

More information about the mocha-developer mailing list