boleto_bancario 0.0.1.beta → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -2
- data/.travis.yml +10 -0
- data/Changelog.markdown +4 -0
- data/Gemfile +1 -1
- data/Planning.markdown +18 -86
- data/README.markdown +107 -55
- data/Rakefile +7 -1
- data/TODO.markdown +15 -1
- data/boleto_bancario.gemspec +7 -3
- data/lib/boleto_bancario.rb +27 -15
- data/lib/boleto_bancario/calculos/modulo11_fator_de9a2.rb +65 -0
- data/lib/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x.rb +5 -51
- data/lib/boleto_bancario/calculos/modulo_numero_de_controle.rb +117 -0
- data/lib/boleto_bancario/core/banco_brasil.rb +30 -5
- data/lib/boleto_bancario/core/banrisul.rb +182 -0
- data/lib/boleto_bancario/core/boleto.rb +67 -34
- data/lib/boleto_bancario/core/bradesco.rb +28 -16
- data/lib/boleto_bancario/core/caixa.rb +233 -0
- data/lib/boleto_bancario/core/hsbc.rb +170 -0
- data/lib/boleto_bancario/core/itau.rb +20 -10
- data/lib/boleto_bancario/core/real.rb +177 -0
- data/lib/boleto_bancario/core/santander.rb +19 -22
- data/lib/boleto_bancario/core/sicoob.rb +172 -0
- data/lib/boleto_bancario/core/sicredi.rb +290 -0
- data/lib/boleto_bancario/version.rb +1 -2
- data/spec/boleto_bancario/calculos/modulo10_spec.rb +4 -0
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_spec.rb +6 -0
- data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_spec.rb +31 -0
- data/spec/boleto_bancario/calculos/modulo_numero_de_controle_spec.rb +37 -0
- data/spec/boleto_bancario/core/banco_brasil_spec.rb +59 -65
- data/spec/boleto_bancario/core/banrisul_spec.rb +129 -0
- data/spec/boleto_bancario/core/boleto_spec.rb +148 -32
- data/spec/boleto_bancario/core/bradesco_spec.rb +29 -36
- data/spec/boleto_bancario/core/caixa_spec.rb +111 -0
- data/spec/boleto_bancario/core/hsbc_spec.rb +72 -0
- data/spec/boleto_bancario/core/itau_spec.rb +33 -36
- data/spec/boleto_bancario/core/real_spec.rb +104 -0
- data/spec/boleto_bancario/core/santander_spec.rb +26 -24
- data/spec/boleto_bancario/core/sicoob_spec.rb +111 -0
- data/spec/boleto_bancario/core/sicredi_spec.rb +149 -0
- data/spec/inheritance/banco_brasil_spec.rb +22 -0
- data/spec/inheritance/banrisul_spec.rb +22 -0
- data/spec/inheritance/boleto_spec.rb +15 -0
- data/spec/inheritance/bradesco_spec.rb +22 -0
- data/spec/inheritance/caixa_spec.rb +22 -0
- data/spec/inheritance/hsbc_spec.rb +22 -0
- data/spec/inheritance/itau_spec.rb +22 -0
- data/spec/inheritance/real_spec.rb +22 -0
- data/spec/inheritance/santander_spec.rb +22 -0
- data/spec/inheritance/sicoob_spec.rb +22 -0
- data/spec/inheritance/sicredi_spec.rb +22 -0
- data/spec/shared_examples/boleto_bancario_shared_example.rb +21 -34
- data/spec/spec_helper.rb +2 -2
- metadata +119 -47
- data/.rvmrc +0 -1
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module BoletoBancario
|
4
|
+
module Core
|
5
|
+
describe Banrisul do
|
6
|
+
it_should_behave_like 'boleto bancario'
|
7
|
+
|
8
|
+
describe "on validations" do
|
9
|
+
it "agencia should have 3 digits" do
|
10
|
+
should have_valid(:agencia).when("1", "123", 1, 123)
|
11
|
+
should_not have_valid(:agencia).when(nil, "", "1234")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "codigo cedente should have 07 digits" do
|
15
|
+
should have_valid(:codigo_cedente).when("1234567", "12", "12345")
|
16
|
+
should_not have_valid(:codigo_cedente).when(nil, "", "12345678", "123456789")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "numero documento should have 8 digits" do
|
20
|
+
should have_valid(:numero_documento).when("12345678", "1234")
|
21
|
+
should_not have_valid(:numero_documento).when(nil, "", "123456789")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "carteira is supported" do
|
25
|
+
should have_valid(:carteira).when('00', '08', 0, 8)
|
26
|
+
should_not have_valid(:carteira).when(nil, '', '5', '20', '100')
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#valor_documento" do
|
30
|
+
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
31
|
+
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#agencia" do
|
36
|
+
context "when have a value" do
|
37
|
+
subject { Banrisul.new(agencia: '34') }
|
38
|
+
|
39
|
+
it { expect(subject.agencia).to eq '034' }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when is nil" do
|
43
|
+
subject { Banrisul.new(agencia: nil) }
|
44
|
+
|
45
|
+
it { expect(subject.agencia).to be nil }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#numero_documento" do
|
50
|
+
context "when have a value" do
|
51
|
+
subject { Banrisul.new(numero_documento: '1234') }
|
52
|
+
|
53
|
+
it { expect(subject.numero_documento).to eq '00001234' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when is nil" do
|
57
|
+
subject { Banrisul.new(numero_documento: nil) }
|
58
|
+
|
59
|
+
it { expect(subject.numero_documento).to be nil }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#codigo_cedente" do
|
64
|
+
context "when have a value" do
|
65
|
+
subject { Banrisul.new(codigo_cedente: '1234') }
|
66
|
+
|
67
|
+
it { expect(subject.codigo_cedente).to eq '0001234' }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when is nil" do
|
71
|
+
subject { Banrisul.new(codigo_cedente: nil) }
|
72
|
+
|
73
|
+
it { expect(subject.codigo_cedente).to be nil }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#codigo_banco" do
|
78
|
+
it { expect(subject.codigo_banco).to eq '041' }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#digito_codigo_banco" do
|
82
|
+
it { expect(subject.digito_codigo_banco).to eq '8' }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#agencia_codigo_cedente" do
|
86
|
+
subject { Banrisul.new(agencia: '100', codigo_cedente: '0000001') }
|
87
|
+
|
88
|
+
it { expect(subject.agencia_codigo_cedente).to eq '100.81 0000001.83' }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#nosso_numero" do
|
92
|
+
context "using one example from documentation" do
|
93
|
+
subject { Banrisul.new(numero_documento: '00009194') }
|
94
|
+
|
95
|
+
it { expect(subject.nosso_numero).to eq '00009194.38' }
|
96
|
+
end
|
97
|
+
|
98
|
+
context "using other example from documentation" do
|
99
|
+
subject { Banrisul.new(numero_documento: '00009274') }
|
100
|
+
|
101
|
+
it { expect(subject.nosso_numero).to eq '00009274.22' }
|
102
|
+
end
|
103
|
+
|
104
|
+
context "another example" do
|
105
|
+
subject { Banrisul.new(numero_documento: '22832563') }
|
106
|
+
|
107
|
+
it { expect(subject.nosso_numero).to eq '22832563.51' }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#codigo_de_barras" do
|
112
|
+
context "one example" do
|
113
|
+
subject do
|
114
|
+
Banrisul.new do |boleto|
|
115
|
+
boleto.numero_documento = 22832563
|
116
|
+
boleto.agencia = 100
|
117
|
+
boleto.data_vencimento = Date.parse('2004-07-04')
|
118
|
+
boleto.codigo_cedente = "0000001"
|
119
|
+
boleto.valor_documento = 5.0
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it { expect(subject.codigo_de_barras).to eq '04197246200000005002110000000012283256304168' }
|
124
|
+
it { expect(subject.linha_digitavel).to eq '04192.11008 00000.012286 32563.041683 7 24620000000500' }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -4,6 +4,34 @@ require 'spec_helper'
|
|
4
4
|
module BoletoBancario
|
5
5
|
module Core
|
6
6
|
describe Boleto do
|
7
|
+
describe '.model_name' do
|
8
|
+
it 'returns Boleto' do
|
9
|
+
expect(Boleto.model_name).to eq 'BoletoBancario::Core::Boleto'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.human_attribute_name' do
|
14
|
+
it 'respond to internationalization attribute' do
|
15
|
+
expect(Boleto).to respond_to(:human_attribute_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#to_partial_path' do
|
20
|
+
subject(:boleto) { Boleto.new }
|
21
|
+
|
22
|
+
it 'returns the path from class name' do
|
23
|
+
expect(boleto.to_partial_path).to eq 'boleto_bancario/boleto'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#to_model' do
|
28
|
+
subject(:boleto) { Boleto.new }
|
29
|
+
|
30
|
+
it 'returns the same object for comparison purposes' do
|
31
|
+
expect(boleto.to_model).to eq boleto
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
7
35
|
describe '#initialize' do
|
8
36
|
context 'when passing a Hash' do
|
9
37
|
subject do
|
@@ -13,31 +41,41 @@ module BoletoBancario
|
|
13
41
|
:data_vencimento => Date.new(2012, 10, 10),
|
14
42
|
:carteira => '175',
|
15
43
|
:agencia => '0098',
|
16
|
-
:digito_agencia => '1',
|
17
44
|
:conta_corrente => '98701',
|
18
45
|
:cedente => 'Nome da razao social',
|
19
46
|
:sacado => 'Teste',
|
20
47
|
:documento_sacado => '725.275.005-10',
|
21
|
-
:endereco_sacado => 'Rua teste, 23045'
|
48
|
+
:endereco_sacado => 'Rua teste, 23045',
|
49
|
+
:instrucoes1 => 'Lembrar de algo 1',
|
50
|
+
:instrucoes2 => 'Lembrar de algo 2',
|
51
|
+
:instrucoes3 => 'Lembrar de algo 3',
|
52
|
+
:instrucoes4 => 'Lembrar de algo 4',
|
53
|
+
:instrucoes5 => 'Lembrar de algo 5',
|
54
|
+
:instrucoes6 => 'Lembrar de algo 6',
|
22
55
|
)
|
23
56
|
end
|
24
57
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
58
|
+
it { expect(subject.numero_documento).to eq '191075' }
|
59
|
+
it { expect(subject.valor_documento).to eq 101.99 }
|
60
|
+
it { expect(subject.data_vencimento).to eq Date.new(2012, 10, 10) }
|
61
|
+
it { expect(subject.carteira).to eq '175' }
|
62
|
+
it { expect(subject.agencia).to eq '0098' }
|
63
|
+
it { expect(subject.conta_corrente).to eq '98701' }
|
64
|
+
it { expect(subject.codigo_moeda).to eq '9' }
|
65
|
+
it { expect(subject.cedente).to eq 'Nome da razao social' }
|
66
|
+
it { expect(subject.especie).to eq 'R$' }
|
67
|
+
it { expect(subject.especie_documento).to eq 'DM' }
|
68
|
+
it { expect(subject.data_documento).to eq Date.today }
|
69
|
+
it { expect(subject.sacado).to eq 'Teste' }
|
70
|
+
it { expect(subject.documento_sacado).to eq '725.275.005-10' }
|
71
|
+
it { expect(subject.endereco_sacado).to eq 'Rua teste, 23045' }
|
72
|
+
it { expect(subject.local_pagamento).to eq 'PAGÁVEL EM QUALQUER BANCO ATÉ O VENCIMENTO' }
|
73
|
+
it { expect(subject.instrucoes1).to eq 'Lembrar de algo 1' }
|
74
|
+
it { expect(subject.instrucoes2).to eq 'Lembrar de algo 2' }
|
75
|
+
it { expect(subject.instrucoes3).to eq 'Lembrar de algo 3' }
|
76
|
+
it { expect(subject.instrucoes4).to eq 'Lembrar de algo 4' }
|
77
|
+
it { expect(subject.instrucoes5).to eq 'Lembrar de algo 5' }
|
78
|
+
it { expect(subject.instrucoes6).to eq 'Lembrar de algo 6' }
|
41
79
|
end
|
42
80
|
|
43
81
|
context 'when passing a block' do
|
@@ -54,27 +92,105 @@ module BoletoBancario
|
|
54
92
|
boleto.cedente = 'Nome da razao social'
|
55
93
|
boleto.documento_cedente = '62.526.713/0001-40'
|
56
94
|
boleto.sacado = 'Teste'
|
95
|
+
boleto.instrucoes1 = 'Lembrar de algo 1'
|
96
|
+
boleto.instrucoes2 = 'Lembrar de algo 2'
|
97
|
+
boleto.instrucoes3 = 'Lembrar de algo 3'
|
98
|
+
boleto.instrucoes4 = 'Lembrar de algo 4'
|
99
|
+
boleto.instrucoes5 = 'Lembrar de algo 5'
|
100
|
+
boleto.instrucoes6 = 'Lembrar de algo 6'
|
57
101
|
end
|
58
102
|
end
|
59
103
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
104
|
+
it { expect(subject.numero_documento).to eq '187390' }
|
105
|
+
it { expect(subject.valor_documento).to eq 1 }
|
106
|
+
it { expect(subject.carteira).to eq '109' }
|
107
|
+
it { expect(subject.agencia).to eq '0914' }
|
108
|
+
it { expect(subject.conta_corrente).to eq '82369' }
|
109
|
+
it { expect(subject.codigo_moeda).to eq '9' }
|
110
|
+
it { expect(subject.codigo_cedente).to eq '90182' }
|
111
|
+
it { expect(subject.endereco_cedente).to eq 'Rua Itapaiuna, 2434' }
|
112
|
+
it { expect(subject.cedente).to eq 'Nome da razao social' }
|
113
|
+
it { expect(subject.documento_cedente).to eq '62.526.713/0001-40' }
|
114
|
+
it { expect(subject.sacado).to eq 'Teste' }
|
115
|
+
it { expect(subject.aceite).to be true }
|
116
|
+
it { expect(subject.instrucoes1).to eq 'Lembrar de algo 1' }
|
117
|
+
it { expect(subject.instrucoes2).to eq 'Lembrar de algo 2' }
|
118
|
+
it { expect(subject.instrucoes3).to eq 'Lembrar de algo 3' }
|
119
|
+
it { expect(subject.instrucoes4).to eq 'Lembrar de algo 4' }
|
120
|
+
it { expect(subject.instrucoes5).to eq 'Lembrar de algo 5' }
|
121
|
+
it { expect(subject.instrucoes6).to eq 'Lembrar de algo 6' }
|
71
122
|
end
|
72
123
|
end
|
73
124
|
|
74
125
|
describe "#carteira_formatada" do
|
75
|
-
it "
|
126
|
+
it "returns 'carteira' as default" do
|
76
127
|
subject.stub(:carteira).and_return('Foo')
|
77
|
-
|
128
|
+
|
129
|
+
expect(subject.carteira_formatada).to eq 'Foo'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#valor_documento_formatado" do
|
134
|
+
context "when period" do
|
135
|
+
before { subject.stub(:valor_documento).and_return(123.45) }
|
136
|
+
|
137
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000012345' }
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when less than ten" do
|
141
|
+
before { subject.stub(:valor_documento).and_return(5.0) }
|
142
|
+
|
143
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000000500' }
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when have many decimal points" do
|
147
|
+
before { subject.stub(:valor_documento).and_return(10.999999) }
|
148
|
+
|
149
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000001099' }
|
150
|
+
end
|
151
|
+
|
152
|
+
context "when integer" do
|
153
|
+
before { subject.stub(:valor_documento).and_return(1_999) }
|
154
|
+
|
155
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000199900' }
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when period with string" do
|
159
|
+
before { subject.stub(:valor_documento).and_return('236.91') }
|
160
|
+
|
161
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000023691' }
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when period with string with many decimals" do
|
165
|
+
before { subject.stub(:valor_documento).and_return('10.999999') }
|
166
|
+
|
167
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000001099' }
|
168
|
+
end
|
169
|
+
|
170
|
+
context "when the cents is not broken" do
|
171
|
+
before { subject.stub(:valor_documento).and_return(229.5) }
|
172
|
+
|
173
|
+
it { expect(subject.valor_formatado_para_codigo_de_barras).to eq '0000022950' }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#aceite_formatado" do
|
178
|
+
context "when is true" do
|
179
|
+
subject { described_class.new(aceite: true) }
|
180
|
+
|
181
|
+
it { expect(subject.aceite_formatado).to eq 'S' }
|
182
|
+
end
|
183
|
+
|
184
|
+
context "when is false" do
|
185
|
+
subject { described_class.new(aceite: false) }
|
186
|
+
|
187
|
+
it { expect(subject.aceite_formatado).to eq 'N' }
|
188
|
+
end
|
189
|
+
|
190
|
+
context "when is nil" do
|
191
|
+
subject { described_class.new(aceite: nil) }
|
192
|
+
|
193
|
+
it { expect(subject.aceite_formatado).to eq 'N' }
|
78
194
|
end
|
79
195
|
end
|
80
196
|
|
@@ -99,4 +215,4 @@ module BoletoBancario
|
|
99
215
|
end
|
100
216
|
end
|
101
217
|
end
|
102
|
-
end
|
218
|
+
end
|
@@ -10,31 +10,28 @@ module BoletoBancario
|
|
10
10
|
it { should have_valid(:agencia).when('1', '123', '1234') }
|
11
11
|
it { should_not have_valid(:agencia).when('12345', '123456', '1234567', nil, '') }
|
12
12
|
|
13
|
-
it { should have_valid(:digito_agencia).when('1', 'X', '4') }
|
14
|
-
it { should_not have_valid(:digito_agencia).when(nil, '', '12', '123') }
|
15
|
-
|
16
13
|
it { should have_valid(:conta_corrente).when('1', '123', '1234') }
|
17
14
|
it { should_not have_valid(:conta_corrente).when('12345678', '123456789', nil, '') }
|
18
15
|
|
19
|
-
it { should have_valid(:digito_conta_corrente).when('1', '4', 'X') }
|
20
|
-
it { should_not have_valid(:digito_conta_corrente).when(nil, '', '12', '123') }
|
21
|
-
|
22
|
-
it { should have_valid(:carteira).when(6, '6', '13') }
|
23
|
-
it { should_not have_valid(:carteira).when('', nil, '102', '123') }
|
24
|
-
|
25
16
|
it { should have_valid(:numero_documento).when(12345678911, '12345678911', '13') }
|
26
17
|
it { should_not have_valid(:numero_documento).when('', nil, 123456789112, 1234567891113) }
|
18
|
+
|
19
|
+
it { should have_valid(:carteira).when('03', '06', '09', '19', '21', '22', 3, 9, 19, 21, 22) }
|
20
|
+
it { should_not have_valid(:carteira).when(nil, '', '05', '20', '100') }
|
21
|
+
|
22
|
+
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
23
|
+
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
27
24
|
end
|
28
25
|
|
29
26
|
describe "#agencia" do
|
30
27
|
context "when have a value" do
|
31
28
|
subject { Bradesco.new(:agencia => 2) }
|
32
29
|
|
33
|
-
|
30
|
+
it { expect(subject.agencia).to eq '0002' }
|
34
31
|
end
|
35
32
|
|
36
33
|
context "when is nil" do
|
37
|
-
|
34
|
+
it { expect(subject.agencia).to be nil }
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
@@ -42,11 +39,11 @@ module BoletoBancario
|
|
42
39
|
context "when have a value" do
|
43
40
|
subject { Bradesco.new(:conta_corrente => 1) }
|
44
41
|
|
45
|
-
|
42
|
+
it { expect(subject.conta_corrente).to eq '0000001' }
|
46
43
|
end
|
47
44
|
|
48
45
|
context "when is nil" do
|
49
|
-
|
46
|
+
it { expect(subject.conta_corrente).to be nil }
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
@@ -54,11 +51,11 @@ module BoletoBancario
|
|
54
51
|
context "when have a value" do
|
55
52
|
subject { Bradesco.new(:numero_documento => 1234) }
|
56
53
|
|
57
|
-
|
54
|
+
it { expect(subject.numero_documento).to eq '00000001234' }
|
58
55
|
end
|
59
56
|
|
60
57
|
context "when is nil" do
|
61
|
-
|
58
|
+
it { expect(subject.numero_documento).to be nil }
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
@@ -66,11 +63,11 @@ module BoletoBancario
|
|
66
63
|
context "when have a value" do
|
67
64
|
subject { Bradesco.new(:carteira => 3) }
|
68
65
|
|
69
|
-
|
66
|
+
it { expect(subject.carteira).to eq '03' }
|
70
67
|
end
|
71
68
|
|
72
69
|
context "when is nil" do
|
73
|
-
|
70
|
+
it { expect(subject.carteira).to be nil }
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
@@ -78,53 +75,53 @@ module BoletoBancario
|
|
78
75
|
context "when carteira is '21'" do
|
79
76
|
subject { Bradesco.new(:carteira => 21) }
|
80
77
|
|
81
|
-
|
78
|
+
it { expect(subject.carteira_formatada).to eq '21 – Cobrança Interna Com Registro' }
|
82
79
|
end
|
83
80
|
|
84
81
|
context "when carteira is '22'" do
|
85
82
|
subject { Bradesco.new(:carteira => 22) }
|
86
83
|
|
87
|
-
|
84
|
+
it { expect(subject.carteira_formatada).to eq '22 – Cobrança Interna sem registro' }
|
88
85
|
end
|
89
86
|
|
90
87
|
context "when carteira is '03'" do
|
91
88
|
subject { Bradesco.new(:carteira => 3) }
|
92
89
|
|
93
|
-
|
90
|
+
it { expect(subject.carteira_formatada).to eq '03' }
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
94
|
describe "#codigo_banco" do
|
98
|
-
|
95
|
+
it { expect(subject.codigo_banco).to eq '237' }
|
99
96
|
end
|
100
97
|
|
101
98
|
describe "#digito_codigo_banco" do
|
102
|
-
|
99
|
+
it { expect(subject.digito_codigo_banco).to eq '2' }
|
103
100
|
end
|
104
101
|
|
105
102
|
describe "#agencia_codigo_cedente" do
|
106
|
-
subject { Bradesco.new(agencia: '1172',
|
103
|
+
subject { Bradesco.new(agencia: '1172', conta_corrente: '0403005') }
|
107
104
|
|
108
|
-
|
105
|
+
it { expect(subject.agencia_codigo_cedente).to eq '1172-10 / 0403005-2' }
|
109
106
|
end
|
110
107
|
|
111
108
|
describe "#nosso_numero" do
|
112
109
|
context "documentation example" do
|
113
110
|
subject { Bradesco.new(:carteira => '19', :numero_documento => '00000000002') }
|
114
111
|
|
115
|
-
|
112
|
+
it { expect(subject.nosso_numero).to eq '19/00000000002-8' }
|
116
113
|
end
|
117
114
|
|
118
115
|
context "more examples from documentation" do
|
119
116
|
subject { Bradesco.new(:carteira => '19', :numero_documento => '00000000001') }
|
120
117
|
|
121
|
-
|
118
|
+
it { expect(subject.nosso_numero).to eq '19/00000000001-P' }
|
122
119
|
end
|
123
120
|
|
124
121
|
context "more examples" do
|
125
122
|
subject { Bradesco.new(:carteira => '06', :numero_documento => '00075896452') }
|
126
123
|
|
127
|
-
|
124
|
+
it { expect(subject.nosso_numero).to eq '06/00075896452-5' }
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
@@ -137,14 +134,12 @@ module BoletoBancario
|
|
137
134
|
boleto.valor_documento = 2952.95
|
138
135
|
boleto.data_vencimento = Date.parse('2012-12-28')
|
139
136
|
boleto.agencia = 1172
|
140
|
-
boleto.digito_agencia = 0
|
141
137
|
boleto.conta_corrente = 403005
|
142
|
-
boleto.digito_conta_corrente = 2
|
143
138
|
end
|
144
139
|
end
|
145
140
|
|
146
|
-
|
147
|
-
|
141
|
+
it { expect(subject.codigo_de_barras).to eq '23796556100002952951172060007589645204030050' }
|
142
|
+
it { expect(subject.linha_digitavel).to eq '23791.17209 60007.589645 52040.300502 6 55610000295295' }
|
148
143
|
end
|
149
144
|
|
150
145
|
context "when carteira '09'" do
|
@@ -155,16 +150,14 @@ module BoletoBancario
|
|
155
150
|
boleto.valor_documento = 2959.78
|
156
151
|
boleto.data_vencimento = Date.parse('2012-12-28')
|
157
152
|
boleto.agencia = 1172
|
158
|
-
boleto.digito_agencia = 0
|
159
153
|
boleto.conta_corrente = 403005
|
160
|
-
boleto.digito_conta_corrente = 2
|
161
154
|
end
|
162
155
|
end
|
163
156
|
|
164
|
-
|
165
|
-
|
157
|
+
it { expect(subject.codigo_de_barras).to eq '23791556100002959781172090017589645104030050' }
|
158
|
+
it { expect(subject.linha_digitavel).to eq '23791.17209 90017.589640 51040.300504 1 55610000295978' }
|
166
159
|
end
|
167
160
|
end
|
168
161
|
end
|
169
162
|
end
|
170
|
-
end
|
163
|
+
end
|