Unit Testing Custom Validation Method

I posted this on comp.lang.ruby and thought it would be in my best interest to post it here too.

I've written a custom validation method (to validate an email address). It looks like

module ActiveRecord   module Validations     module ClassMethods

      def validates_as_email         ...       end

    end   end end

I've put this code in app/lib/custom_validations.rb

Now, I'm trying to write a unit test but I'm running into problems. One attempt at a unit test looks like

require File.dirname(__FILE__) + '/../test_helper' require 'lib/custom_validations'

class CustomValidationsTest < Test::Unit::TestCase

  def test_validates_as_email     email = "some...@example.com"     assert validates_as_email( email )   end end

This throws a NoMethodError: undefined method `validates_as_email' for #<CustomValidationsTest:0x314bd80> It looks to me like the test is looking for the validates_as_email method to be defined in CustomValidationsTest rather than finding it in lib/custom_validations.rb

So, I tried this

require File.dirname(__FILE__) + '/../test_helper' require 'lib/custom_validations'

class CustomValidationsTest < Test::Unit::TestCase

  def test_validates_as_email     email = "some...@example.com"     assert ActiveRecord::Validations::ClassMethods.validates_as_email( email )   end end

And I got this error NoMethodError: undefined method `validates_as_email' for ActiveRecord::Validations::ClassMethods:Module

What am I missing? I'll bet it's something simple, but I just can't figure out what's wrong. Thanks for the help.