Created
September 19, 2011 12:53
-
-
Save jeffkreeftmeijer/1226439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PirateValidator < ActiveModel::Validator | |
def validate(document) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_model' | |
require File.expand_path('app/validators/pirate_validator') | |
class Validatable | |
include ActiveModel::Validations | |
validates_with PirateValidator | |
end | |
describe PirateValidator do | |
subject { Validatable.new } | |
context 'with a comment that sounds like a pirate' do | |
before { subject.stub(:comment).and_return('Ahoy, matey!') } | |
it { should be_valid } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't want to load up
spec/rails/extensions
? Put validations.rb in yoursupport
directory andrequire 'support/validations'
instead. It saves me ~ 2 seconds. :)