Sha256: 3ae35d458f3ded7124c6afa4a7e2936625c8bd0af0a64ca3b057a366b7d3bd0e
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe CpfValidator do let(:user) { User.new } context 'with invalid cpf' do before do user.cpf = '12345' I18n.stub(:t).with(:'activerecord.errors.models.user.attributes.cpf.invalid', default: :'activerecord.errors.messages.invalid').and_return('is invalid') user.valid? end it 'invalidates the object' do expect(user).not_to be_valid end it 'sets an error message' do expect(user.errors[:cpf]).to match(['is invalid']) end end context 'with valid cpf' do before do user.cpf = '11144477735' user.valid? end it 'validates the object' do expect(user).to be_valid end it 'does not set an error message' do expect(user.errors[:cpf]).to be_blank end end context 'with nil value' do before { user.cpf = nil } it 'validates the object' do expect(user).to be_valid end it 'does not set an error message' do expect(user.errors[:cpf]).to be_blank end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validates_cpf-3.1.0 | spec/cpf_validator_spec.rb |
validates_cpf-3.0.0 | spec/cpf_validator_spec.rb |