[rspec-users] spec'ing validates_uniqueness_of :whatever

Courtenay court3nay at gmail.com
Fri Apr 4 01:03:16 EDT 2008

On Thu, Apr 3, 2008 at 4:38 AM, Juanma Cervera <lists at ruby-forum.com> wrote:
> Thanks to all for your answers.
>  I also have found a plugin with matchers for active record validations,
>  associations and even useful matchers for views.
>  It has a matcher for validates_uniqueness_of that doesn't got to the
>  database.

The test asserts that you call validates_uniqueness_of, but it doesn't
actually test your logic.
So it's useful to see if someone accidentally deletes your code, but if you have

    validates_uniqueness_of :user, :scope => :project_id

or something more complex, it won't test this behavior.

More information about the rspec-users mailing list