Skip to content

Instantly share code, notes, and snippets.

@jeffkreeftmeijer
Created September 19, 2011 12:53
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jeffkreeftmeijer/1226439 to your computer and use it in GitHub Desktop.
class PirateValidator < ActiveModel::Validator
end
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
@jeffkreeftmeijer
Copy link
Author

Don't want to load up spec/rails/extensions? Put validations.rb in your support directory and require 'support/validations' instead. It saves me ~ 2 seconds. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment