Sha256: 573175243f5171e2198e75fc45d2b98fd079ffd901248095ed2046a794f1ad90

Contents?: true

Size: 648 Bytes

Versions: 3

Compression:

Stored size: 648 Bytes

Contents

require 'spec_helper'
require 'shoulda-matchers'

describe Shoulda::Matchers::ActiveModel::ValidateAsCpfMatcher do
  context "on a attribute which validates cpf" do
    it "should require a valid CPF" do
      @user = User.new(:cpf => '123456')
      @user.should validate_as_cpf(:cpf)
    end

    it "should allow a nil value" do
      @user = User.new(:cpf => nil)
      @user.should validate_as_cpf(:cpf)
    end
  end

  context "on a attribute which not validates cpf" do
    before do
      @user = Admin.new(:cpf => '123456')
    end

    it "should not require a valid CPF" do
      @user.should_not validate_as_cpf(:cpf)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
validates_cpf-0.2.2 spec/shoulda-matchers/validate_as_cpf_matcher_spec.rb
validates_cpf-0.2.1 spec/shoulda-matchers/validate_as_cpf_matcher_spec.rb
validates_cpf-0.2.0 spec/shoulda-matchers/validate_as_cpf_matcher_spec.rb