test/unit/validations_test.rb in cieloz-0.0.19 vs test/unit/validations_test.rb in cieloz-0.0.20

- old
+ new

@@ -244,9 +244,32 @@ refute txn.valid? refute txn.errors[:forma_pagamento].empty? end end +describe Cieloz::RequisicaoTransacao::DadosAvs do + it { must_validate_presence_of :cep } + + it 'validates format of cep' do + subject.cep = '12345-123' + assert subject.valid? + + subject.cep = '12345123' + refute subject.valid? + assert_equal [I18n.t('errors.messages.invalid')], subject.errors[:cep] + + subject.cep = '12345-abc' + refute subject.valid? + assert_equal [I18n.t('errors.messages.invalid')], subject.errors[:cep] + end + + it "is validated inside RequisicaoTransacao" do + txn = Cieloz::RequisicaoTransacao.new dados_avs: subject + refute txn.valid? + refute txn.errors[:dados_avs].empty? + end +end + describe Cieloz::RequisicaoTransacao do let(:_) { subject.class } it { must_validate_presence_of :dados_pedido } it { must_validate_presence_of :forma_pagamento }