Create a gist now

Instantly share code, notes, and snippets.

class PirateValidator < ActiveModel::Validator
require 'active_model'
require File.expand_path('app/validators/pirate_validator')
class Validatable
include ActiveModel::Validations
validates_with PirateValidator
describe PirateValidator do
subject { }
context 'with a comment that sounds like a pirate' do
before { subject.stub(:comment).and_return('Ahoy, matey!') }
it { should be_valid }

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