Sha256: ca99bb8ba0e9e81103a86528f08f64c92a695877738159c34bbd239e77feaf59
Contents?: true
Size: 816 Bytes
Versions: 1
Compression:
Stored size: 816 Bytes
Contents
require 'remarkable/active_record' module Remarkable module ActiveRecord module Matchers class ValidateAsCpfMatcher < Remarkable::ActiveRecord::Base arguments :as => :cpf collection_assertions :cpf_valid?, :allow_nil?, :formatted_number? protected def cpf_valid? @subject.cpf = '123456' @subject.valid?.errors[:cpf].should == ['is invalid'] end def allow_nil? @subject.cpf = nil @subject.valid?.errors[:cpf].should == [] end def formatted_number? @subject.cpf = '55658208394' @subject.valid?.cpf.should == '556.582.083-94' end end def validates_as_cpf(*args, &block) ValidateAsCpfMatcher.new(*args, &block).spec(self) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_cpf-0.2.0 | lib/remarkable/validate_as_cpf_matcher.rb |