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,111 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module BoletoBancario
|
5
|
+
module Core
|
6
|
+
describe Caixa do
|
7
|
+
it_should_behave_like 'boleto bancario'
|
8
|
+
|
9
|
+
describe "on validations" do
|
10
|
+
it { should have_valid(:agencia).when(1, 1234, '1', '1234') }
|
11
|
+
it { should_not have_valid(:agencia).when(12345, '12345', nil, '') }
|
12
|
+
|
13
|
+
it { should have_valid(:codigo_cedente).when(1, 123456, '1', '123456') }
|
14
|
+
it { should_not have_valid(:codigo_cedente).when(1234567, '1234567', nil, '') }
|
15
|
+
|
16
|
+
it { should have_valid(:carteira).when(14, 24, '14', '24') }
|
17
|
+
it { should_not have_valid(:carteira).when(nil, '', 5, 20, '20', '100') }
|
18
|
+
|
19
|
+
it { should have_valid(:numero_documento).when(1, 123456789112345, '1', '123456789112345') }
|
20
|
+
it { should_not have_valid(:numero_documento).when(nil, '', 1234567891123456, '1234567891123456') }
|
21
|
+
|
22
|
+
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 9_999_999.99, '100.99') }
|
23
|
+
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 10_000_000.00) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#agencia" do
|
27
|
+
context "when have a value" do
|
28
|
+
subject { Caixa.new(agencia: 2) }
|
29
|
+
|
30
|
+
it { expect(subject.agencia).to eq '0002' }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when is nil" do
|
34
|
+
it { expect(subject.agencia).to be nil }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#codigo_cedente" do
|
39
|
+
context "when have a value" do
|
40
|
+
subject { Caixa.new(codigo_cedente: '1') }
|
41
|
+
|
42
|
+
it { expect(subject.codigo_cedente).to eq '000001' }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when is nil" do
|
46
|
+
it { expect(subject.codigo_cedente).to be nil }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#numero_documento" do
|
51
|
+
context "when have a value" do
|
52
|
+
subject { Caixa.new(numero_documento: 1234) }
|
53
|
+
|
54
|
+
it { expect(subject.numero_documento).to eq '000000000001234' }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when is nil" do
|
58
|
+
it { expect(subject.numero_documento).to be nil }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#carteira" do
|
63
|
+
context "when have a value" do
|
64
|
+
subject { Caixa.new(carteira: '24') }
|
65
|
+
|
66
|
+
it { expect(subject.carteira).to eq '24' }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when is nil" do
|
70
|
+
it { expect(subject.carteira).to be nil }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#codigo_banco" do
|
75
|
+
it { expect(subject.codigo_banco).to eq '104' }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#digito_codigo_banco" do
|
79
|
+
it { expect(subject.digito_codigo_banco).to eq '0' }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#agencia_codigo_cedente" do
|
83
|
+
subject { Caixa.new(agencia: '0235', codigo_cedente: '162546') }
|
84
|
+
|
85
|
+
it { expect(subject.agencia_codigo_cedente).to eq '0235 / 162546-2' }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#nosso_numero" do
|
89
|
+
subject { Caixa.new(carteira: '24', numero_documento: '863245679215648') }
|
90
|
+
|
91
|
+
it { expect(subject.nosso_numero).to eq '24863245679215648-2' }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#codigo_de_barras" do
|
95
|
+
subject do
|
96
|
+
Caixa.new do |caixa|
|
97
|
+
caixa.agencia = 1333
|
98
|
+
caixa.codigo_cedente = '792157'
|
99
|
+
caixa.carteira = '14'
|
100
|
+
caixa.numero_documento = '946375189643625'
|
101
|
+
caixa.valor_documento = 2952.95
|
102
|
+
caixa.data_vencimento = Date.parse('2015-03-16')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it { expect(subject.codigo_de_barras).to eq '10492636900002952957921578946137541896436250' }
|
107
|
+
it { expect(subject.linha_digitavel).to eq '10497.92151 78946.137540 18964.362505 2 63690000295295' }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module BoletoBancario
|
5
|
+
module Core
|
6
|
+
describe Hsbc do
|
7
|
+
it_should_behave_like 'boleto bancario'
|
8
|
+
|
9
|
+
describe "on validations" do
|
10
|
+
it { should have_valid(:codigo_cedente).when(1, 1234567, '1', '1234567') }
|
11
|
+
it { should_not have_valid(:codigo_cedente).when(12345678, '12345678', nil, '') }
|
12
|
+
|
13
|
+
it { should have_valid(:numero_documento).when(1, 1234567891123, '1', '1234567891123') }
|
14
|
+
it { should_not have_valid(:numero_documento).when(nil, '', 12345678911234, '12345678911234') }
|
15
|
+
|
16
|
+
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
17
|
+
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.00) }
|
18
|
+
|
19
|
+
it { should have_valid(:carteira).when('CNR') }
|
20
|
+
it { should_not have_valid(:carteira).when(nil, '', '5', 'CSB') }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#codigo_cedente" do
|
24
|
+
context "when have a value" do
|
25
|
+
subject { Hsbc.new(codigo_cedente: '1') }
|
26
|
+
|
27
|
+
it { expect(subject.codigo_cedente).to eq '0000001' }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when is nil" do
|
31
|
+
it { expect(subject.codigo_cedente).to be nil }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#numero_documento" do
|
36
|
+
context "when have a value" do
|
37
|
+
subject { Hsbc.new(numero_documento: 1234) }
|
38
|
+
|
39
|
+
it { expect(subject.numero_documento).to eq '0000000001234' }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when is nil" do
|
43
|
+
it { expect(subject.numero_documento).to be nil }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it { expect(subject.codigo_banco).to eq '399' }
|
48
|
+
|
49
|
+
it { expect(subject.digito_codigo_banco).to eq '9' }
|
50
|
+
|
51
|
+
describe "#nosso_numero" do
|
52
|
+
subject { Hsbc.new(codigo_cedente: '7984135', numero_documento: '4716881775613', data_vencimento: Date.parse('2009-05-22')) }
|
53
|
+
|
54
|
+
it { expect(subject.nosso_numero).to eq '4716881775613440' }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#codigo_de_barras" do
|
58
|
+
subject do
|
59
|
+
Hsbc.new do |hsbc|
|
60
|
+
hsbc.codigo_cedente = 3485910
|
61
|
+
hsbc.numero_documento = '43862'
|
62
|
+
hsbc.valor_documento = 3740.58
|
63
|
+
hsbc.data_vencimento = Date.parse('2024-02-18')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it { expect(subject.codigo_de_barras).to eq '39991963000003740583485910000000004386204942' }
|
68
|
+
it { expect(subject.linha_digitavel).to eq '39993.48596 10000.000009 43862.049426 1 96300000374058' }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -6,9 +6,9 @@ module BoletoBancario
|
|
6
6
|
it_should_behave_like 'boleto bancario'
|
7
7
|
|
8
8
|
describe "on validations" do
|
9
|
-
|
10
|
-
it { should have_valid(:carteira).when('109', '
|
11
|
-
it { should_not have_valid(:carteira).when('
|
9
|
+
context "#carteira" do
|
10
|
+
it { should have_valid(:carteira).when('107', '109', '174', '175', '196', '198', '126', '131', '146', '122', '142', '143', '150', '168', 109, 131, 168) }
|
11
|
+
it { should_not have_valid(:carteira).when(nil, '', '05', '20', '100', '115', '145', '170') }
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#numero_documento" do
|
@@ -26,6 +26,11 @@ module BoletoBancario
|
|
26
26
|
it { should_not have_valid(:agencia).when('12345', nil, '123456', '') }
|
27
27
|
end
|
28
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
|
+
|
29
34
|
describe "#codigo_cedente" do
|
30
35
|
%w(107 122 142 143 196 198).each do |carteira_especial|
|
31
36
|
context "when 'carteira' is special: #{carteira_especial}" do
|
@@ -67,30 +72,25 @@ module BoletoBancario
|
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
70
|
-
|
71
|
-
describe "#digito_conta_corrente" do
|
72
|
-
it { should have_valid(:digito_conta_corrente).when('1', '2', '3') }
|
73
|
-
it { should_not have_valid(:digito_conta_corrente).when('12', nil, '123', '') }
|
74
|
-
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "#numero_documento" do
|
78
78
|
subject { Itau.new(:numero_documento => '123') }
|
79
79
|
|
80
|
-
|
80
|
+
it { expect(subject.numero_documento).to eq '00000123' }
|
81
81
|
end
|
82
82
|
|
83
83
|
describe "#seu_numero" do
|
84
84
|
context "when have a value" do
|
85
85
|
subject { Itau.new(:seu_numero => '11804') }
|
86
86
|
|
87
|
-
|
87
|
+
it { expect(subject.seu_numero).to eq '0011804' }
|
88
88
|
end
|
89
89
|
|
90
90
|
context "when is nil" do
|
91
91
|
subject { Itau.new(:seu_numero => nil) }
|
92
92
|
|
93
|
-
|
93
|
+
it { expect(subject.seu_numero).to be nil }
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -98,13 +98,13 @@ module BoletoBancario
|
|
98
98
|
context "when have a value" do
|
99
99
|
subject { Itau.new(:agencia => '001') }
|
100
100
|
|
101
|
-
|
101
|
+
it { expect(subject.agencia).to eq '0001' }
|
102
102
|
end
|
103
103
|
|
104
104
|
context "when is nil" do
|
105
105
|
subject { Itau.new(:agencia => nil) }
|
106
106
|
|
107
|
-
|
107
|
+
it { expect(subject.agencia).to be nil }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,13 +112,13 @@ module BoletoBancario
|
|
112
112
|
context "when have a value" do
|
113
113
|
subject { Itau.new(:conta_corrente => 9013) }
|
114
114
|
|
115
|
-
|
115
|
+
it { expect(subject.conta_corrente).to eq '09013' }
|
116
116
|
end
|
117
117
|
|
118
118
|
context "when is nil" do
|
119
119
|
subject { Itau.new(:conta_corrente => nil) }
|
120
120
|
|
121
|
-
|
121
|
+
it { expect(subject.conta_corrente).to be nil }
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -126,26 +126,26 @@ module BoletoBancario
|
|
126
126
|
context "when have a value" do
|
127
127
|
subject { Itau.new(:codigo_cedente => 1987) }
|
128
128
|
|
129
|
-
|
129
|
+
it { expect(subject.codigo_cedente).to eq '01987' }
|
130
130
|
end
|
131
131
|
|
132
132
|
context "when is nil" do
|
133
133
|
subject { Itau.new(:codigo_cedente => nil) }
|
134
134
|
|
135
|
-
|
135
|
+
it { expect(subject.codigo_cedente).to be nil }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
139
|
describe "#codigo_banco" do
|
140
|
-
|
140
|
+
it { expect(subject.codigo_banco).to eq '341' }
|
141
141
|
end
|
142
142
|
|
143
143
|
describe "#digito_codigo_banco" do
|
144
|
-
|
144
|
+
it { expect(subject.digito_codigo_banco).to eq '7' }
|
145
145
|
end
|
146
146
|
|
147
147
|
describe "#agencia_codigo_cedente" do
|
148
|
-
subject { Itau.new(:agencia => '0057', :conta_corrente => '12345'
|
148
|
+
subject { Itau.new(:agencia => '0057', :conta_corrente => '12345') }
|
149
149
|
|
150
150
|
it "should return the agency and bank account with digit" do
|
151
151
|
subject.agencia_codigo_cedente.should eq '0057 / 12345-7'
|
@@ -229,13 +229,13 @@ module BoletoBancario
|
|
229
229
|
context "when 'carteira' is special: #{carteira_especial}" do
|
230
230
|
subject { Itau.new(carteira: carteira_especial) }
|
231
231
|
|
232
|
-
|
232
|
+
it { expect(subject.carteira_especial?).to be true }
|
233
233
|
end
|
234
234
|
|
235
235
|
context "when 'carteira' is special: #{carteira_especial} as numeric" do
|
236
236
|
subject { Itau.new(carteira: carteira_especial.to_i) }
|
237
237
|
|
238
|
-
|
238
|
+
it { expect(subject.carteira_especial?).to be true }
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
@@ -243,7 +243,7 @@ module BoletoBancario
|
|
243
243
|
context "when 'carteira' isn't special: #{carteira}" do
|
244
244
|
subject { Itau.new(carteira: carteira) }
|
245
245
|
|
246
|
-
|
246
|
+
it { expect(subject.carteira_especial?).to be false }
|
247
247
|
end
|
248
248
|
end
|
249
249
|
end
|
@@ -256,11 +256,10 @@ module BoletoBancario
|
|
256
256
|
boleto.numero_documento = '12345678'
|
257
257
|
boleto.agencia = '0057'
|
258
258
|
boleto.conta_corrente = '12345'
|
259
|
-
boleto.digito_conta_corrente = '7'
|
260
259
|
end
|
261
260
|
end
|
262
261
|
|
263
|
-
|
262
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1091234567800057123457000' }
|
264
263
|
end
|
265
264
|
|
266
265
|
context "when special 'carteira'" do
|
@@ -276,37 +275,37 @@ module BoletoBancario
|
|
276
275
|
context "when 'carteira' is 107" do
|
277
276
|
let(:carteira) { '107' }
|
278
277
|
|
279
|
-
|
278
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1071234567811089549478620' }
|
280
279
|
end
|
281
280
|
|
282
281
|
context "when 'carteira' is 122" do
|
283
282
|
let(:carteira) { '122' }
|
284
283
|
|
285
|
-
|
284
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1221234567811089549478610' }
|
286
285
|
end
|
287
286
|
|
288
287
|
context "when 'carteira' is 142" do
|
289
288
|
let(:carteira) { '142' }
|
290
289
|
|
291
|
-
|
290
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1421234567811089549478690' }
|
292
291
|
end
|
293
292
|
|
294
293
|
context "when 'carteira' is 143" do
|
295
294
|
let(:carteira) { '143' }
|
296
295
|
|
297
|
-
|
296
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1431234567811089549478670' }
|
298
297
|
end
|
299
298
|
|
300
299
|
context "when 'carteira' is 196" do
|
301
300
|
let(:carteira) { '196' }
|
302
301
|
|
303
|
-
|
302
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1961234567811089549478650' }
|
304
303
|
end
|
305
304
|
|
306
305
|
context "when 'carteira' is 198" do
|
307
306
|
let(:carteira) { '198' }
|
308
307
|
|
309
|
-
|
308
|
+
it { expect(subject.codigo_de_barras_do_banco).to eq '1981234567811089549478610' }
|
310
309
|
end
|
311
310
|
end
|
312
311
|
end
|
@@ -317,20 +316,18 @@ module BoletoBancario
|
|
317
316
|
boleto.carteira = '175'
|
318
317
|
boleto.agencia = 1565
|
319
318
|
boleto.conta_corrente = 13877
|
320
|
-
boleto.digito_conta_corrente = 1
|
321
319
|
boleto.numero_documento = 12345678
|
322
320
|
boleto.data_vencimento = Date.parse('2012-12-21')
|
323
321
|
boleto.valor_documento = 2952.95
|
324
322
|
end
|
325
323
|
end
|
326
324
|
|
327
|
-
|
328
|
-
its(:linha_digitavel) { should eq '34191.75124 34567.861561 51387.710000 1 55540000295295' }
|
325
|
+
it { expect(subject.linha_digitavel).to eq '34191.75124 34567.861561 51387.710000 1 55540000295295' }
|
329
326
|
end
|
330
327
|
|
331
328
|
describe "#to_partial_path" do
|
332
|
-
|
329
|
+
it { expect(subject.to_partial_path).to eq 'boleto_bancario/itau' }
|
333
330
|
end
|
334
331
|
end
|
335
332
|
end
|
336
|
-
end
|
333
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module BoletoBancario
|
5
|
+
module Core
|
6
|
+
describe Real do
|
7
|
+
it_should_behave_like 'boleto bancario'
|
8
|
+
|
9
|
+
describe "on validations" do
|
10
|
+
it { should have_valid(:agencia).when('1', '12', '123', '1234') }
|
11
|
+
it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
|
12
|
+
|
13
|
+
it { should have_valid(:conta_corrente).when('1', '12', '123', '1234567') }
|
14
|
+
it { should_not have_valid(:conta_corrente).when('12345678', '123456789', nil, '') }
|
15
|
+
|
16
|
+
it { should have_valid(:numero_documento).when('1', '12', '123', '1234567891123') }
|
17
|
+
it { should_not have_valid(:numero_documento).when('12345678911234', nil, '') }
|
18
|
+
|
19
|
+
it { should have_valid(:carteira).when('0', 20, '31', 42, '47', 85) }
|
20
|
+
it { should_not have_valid(:carteira).when(nil, '1', 2, '123') }
|
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) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#agencia" do
|
27
|
+
context "when have a value" do
|
28
|
+
subject { Real.new(agencia: '802') }
|
29
|
+
|
30
|
+
it { expect(subject.agencia).to eq '0802' }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when is nil" do
|
34
|
+
it { expect(subject.agencia).to be nil }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#conta_corrente" do
|
39
|
+
context "when have a value" do
|
40
|
+
subject { Real.new(conta_corrente: '1625') }
|
41
|
+
|
42
|
+
it { expect(subject.conta_corrente).to eq '0001625' }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when is nil" do
|
46
|
+
it { expect(subject.conta_corrente).to be nil }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#numero_documento" do
|
51
|
+
context "when have a value" do
|
52
|
+
subject { Real.new(numero_documento: '2483169') }
|
53
|
+
|
54
|
+
it { expect(subject.numero_documento).to eq '0000002483169' }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when is nil" do
|
58
|
+
it { expect(subject.numero_documento).to be nil }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#carteira" do
|
63
|
+
context "when have a value" do
|
64
|
+
subject { Real.new(carteira: '20') }
|
65
|
+
|
66
|
+
it { expect(subject.carteira).to eq '20' }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when is nil" do
|
70
|
+
it { expect(subject.carteira).to be nil }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#codigo_banco" do
|
75
|
+
it { expect(subject.codigo_banco).to eq '356' }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#digito_codigo_banco" do
|
79
|
+
it { expect(subject.digito_codigo_banco).to eq '5' }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#agencia_codigo_beneficiario" do
|
83
|
+
subject { Real.new(agencia: '501', conta_corrente: 6703255) }
|
84
|
+
|
85
|
+
it { expect(subject.agencia_codigo_cedente).to eq '0501/6703255/1' }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#codigo_de_barras" do
|
89
|
+
subject do
|
90
|
+
Real.new do |real|
|
91
|
+
real.agencia = 501
|
92
|
+
real.conta_corrente = '6703255'
|
93
|
+
real.numero_documento = 3020
|
94
|
+
real.valor_documento = 35
|
95
|
+
real.data_vencimento = Date.parse('2001-10-02')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it { expect(subject.codigo_de_barras).to eq '35699145600000035000501670325510000000003020' }
|
100
|
+
it { expect(subject.linha_digitavel).to eq '35690.50168 70325.510009 00000.030205 9 14560000003500' }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|