title: How to test a custom validator?
body: <p>I have the following validator:</p>
  
  <pre><code># Source: http://guides.rubyonrails.org/active_record_validations_callbacks.html#custom-validators
  # app/validators/email_validator.rb
  
  class EmailValidator &lt; ActiveModel::EachValidator
    def validate_each(object, attribute, value)
      unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
        object.errors[attribute] &lt;&lt; (options[:message] || "is not formatted properly") 
      end
    end
  end
  </code></pre>
  
  <p>I would like to be able to test this in RSpec inside of my lib directory.  The problem so far is I am not sure how to initialize an <code>EachValidator</code>. </p>