boleto_bancario 0.0.1.beta → 1.0.0

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.markdown +58 -2
  3. data/README.markdown +679 -156
  4. data/lib/boleto_bancario/calculos/documento.rb +191 -0
  5. data/lib/boleto_bancario/calculos/fator_vencimento.rb +78 -31
  6. data/lib/boleto_bancario/calculos/modulo11_fator_de9a2.rb +65 -0
  7. data/lib/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x.rb +5 -51
  8. data/lib/boleto_bancario/calculos/modulo_numero_de_controle.rb +117 -0
  9. data/lib/boleto_bancario/core/banco_brasil.rb +30 -5
  10. data/lib/boleto_bancario/core/banrisul.rb +182 -0
  11. data/lib/boleto_bancario/core/boleto.rb +97 -35
  12. data/lib/boleto_bancario/core/bradesco.rb +28 -16
  13. data/lib/boleto_bancario/core/c6_bank.rb +155 -0
  14. data/lib/boleto_bancario/core/caixa.rb +233 -0
  15. data/lib/boleto_bancario/core/inter.rb +155 -0
  16. data/lib/boleto_bancario/core/itau.rb +20 -10
  17. data/lib/boleto_bancario/core/nubank.rb +156 -0
  18. data/lib/boleto_bancario/core/santander.rb +19 -22
  19. data/lib/boleto_bancario/core/sicoob.rb +172 -0
  20. data/lib/boleto_bancario/core/sicredi.rb +290 -0
  21. data/lib/boleto_bancario/locales/pt-BR.yml +55 -0
  22. data/lib/boleto_bancario/renderers/base.rb +154 -0
  23. data/lib/boleto_bancario/renderers/html_renderer.rb +92 -0
  24. data/lib/boleto_bancario/renderers/pdf_renderer.rb +130 -0
  25. data/lib/boleto_bancario/renderers/png_renderer.rb +66 -0
  26. data/lib/boleto_bancario/templates/_barcode.html.erb +3 -0
  27. data/lib/boleto_bancario/templates/_cedente.html.erb +14 -0
  28. data/lib/boleto_bancario/templates/_header.html.erb +4 -0
  29. data/lib/boleto_bancario/templates/_instructions.html.erb +10 -0
  30. data/lib/boleto_bancario/templates/_payment.html.erb +36 -0
  31. data/lib/boleto_bancario/templates/_sacado.html.erb +10 -0
  32. data/lib/boleto_bancario/templates/boleto.html.erb +22 -0
  33. data/lib/boleto_bancario/templates/boleto_styles.css +18 -0
  34. data/lib/boleto_bancario/version.rb +3 -2
  35. data/lib/boleto_bancario.rb +48 -19
  36. data/lib/generators/boleto_bancario/views_generator.rb +47 -0
  37. metadata +140 -106
  38. data/.gitignore +0 -18
  39. data/.rspec +0 -1
  40. data/.rvmrc +0 -1
  41. data/Gemfile +0 -3
  42. data/Planning.markdown +0 -131
  43. data/Rakefile +0 -9
  44. data/TODO.markdown +0 -5
  45. data/boleto_bancario.gemspec +0 -25
  46. data/documentacoes_dos_boletos/Bradesco/Manual_BRADESCO.PDF +0 -0
  47. data/spec/boleto_bancario/calculos/digitos_spec.rb +0 -19
  48. data/spec/boleto_bancario/calculos/fator_vencimento_spec.rb +0 -59
  49. data/spec/boleto_bancario/calculos/fatores_de_multiplicacao_spec.rb +0 -69
  50. data/spec/boleto_bancario/calculos/linha_digitavel_spec.rb +0 -57
  51. data/spec/boleto_bancario/calculos/modulo10_spec.rb +0 -49
  52. data/spec/boleto_bancario/calculos/modulo11_fator_de2a7_spec.rb +0 -43
  53. data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_resto_zero_spec.rb +0 -39
  54. data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_spec.rb +0 -61
  55. data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x_spec.rb +0 -37
  56. data/spec/boleto_bancario/calculos/modulo11_spec.rb +0 -19
  57. data/spec/boleto_bancario/core/banco_brasil_spec.rb +0 -383
  58. data/spec/boleto_bancario/core/boleto_spec.rb +0 -102
  59. data/spec/boleto_bancario/core/bradesco_spec.rb +0 -170
  60. data/spec/boleto_bancario/core/itau_spec.rb +0 -336
  61. data/spec/boleto_bancario/core/santander_spec.rb +0 -135
  62. data/spec/shared_examples/boleto_bancario_shared_example.rb +0 -164
  63. data/spec/spec_helper.rb +0 -14
@@ -1,383 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- module BoletoBancario
5
- module Core
6
- describe BancoBrasil do
7
- it_should_behave_like 'boleto bancario'
8
-
9
- describe "on validations" do
10
- context "#agencia" do
11
- it { should have_valid(:agencia).when('123', '1234') }
12
- it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
13
- end
14
-
15
- context "#digito_agencia" do
16
- it { should have_valid(:digito_agencia).when('1', '3', 'X') }
17
- it { should_not have_valid(:digito_agencia).when('12', nil, '') }
18
- end
19
-
20
- context "#conta_corrente" do
21
- it { should have_valid(:conta_corrente).when('12345678', '12345', '1234') }
22
- it { should_not have_valid(:conta_corrente).when('123456789', nil, '') }
23
- end
24
-
25
- context "#digito_conta_corrente" do
26
- it { should have_valid(:digito_conta_corrente).when('1') }
27
- it { should_not have_valid(:digito_conta_corrente).when('12', nil, '') }
28
- end
29
-
30
- context "#codigo_cedente" do
31
- it { should have_valid(:codigo_cedente).when('1234', '123456', '1234567', '12345678') }
32
- it { should_not have_valid(:codigo_cedente).when('123', '1', '12', nil, '') }
33
- end
34
-
35
- context "when 'carteira' is 16 and 'codigo_cedente' 6 digits" do
36
- subject { BancoBrasil.new(carteira: 16, codigo_cedente: 123456) }
37
-
38
- it { should have_valid(:numero_documento).when('1234', '12345', '12345', '12345678911234567') }
39
- it { should_not have_valid(:numero_documento).when(nil, '', '123456', '123456789112345678') }
40
- end
41
-
42
- context "when 'carteira' is 18 and 'codigo_cedente' 6 digits" do
43
- subject { BancoBrasil.new(carteira: 18, codigo_cedente: 123456) }
44
-
45
- it { should have_valid(:numero_documento).when('1234', '12345', '12345678911234567') }
46
- it { should_not have_valid(:numero_documento).when(nil, '', '123456', '1234567', '123456789112345678') }
47
- end
48
-
49
- context "when 'carteira' is 12 and 'codigo_cedente' 6 digits" do
50
- subject { BancoBrasil.new(carteira: 12, codigo_cedente: 123456) }
51
-
52
- it { should have_valid(:numero_documento).when('12345', '1234') }
53
- it { should_not have_valid(:numero_documento).when(nil, '', '123456', '12345678911234567') }
54
- end
55
-
56
- context "when 'codigo_cedente' 4 digits" do
57
- subject { BancoBrasil.new(codigo_cedente: 1234) }
58
-
59
- it { should have_valid(:numero_documento).when('123', '1235', '1234567') }
60
- it { should_not have_valid(:numero_documento).when(nil, '', '12345678', '12345678911234567') }
61
- end
62
-
63
- context "when 'codigo_cedente' 7 digits" do
64
- subject { BancoBrasil.new(codigo_cedente: 1234567) }
65
-
66
- it { should have_valid(:numero_documento).when('1234567890', '1235', '1234567') }
67
- it { should_not have_valid(:numero_documento).when(nil, '', '12345678901', '12345678911234567') }
68
- end
69
-
70
- context "when 'codigo_cedente' 8 digits" do
71
- subject { BancoBrasil.new(codigo_cedente: 12345678) }
72
-
73
- it { should have_valid(:numero_documento).when('123456789', '1235', '1234567') }
74
- it { should_not have_valid(:numero_documento).when(nil, '', '1234567890', '12345678911234567') }
75
- end
76
- end
77
-
78
- describe "#agencia" do
79
- context "when have a value" do
80
- subject { BancoBrasil.new(:agencia => '001') }
81
-
82
- its(:agencia) { should eq '0001' }
83
- end
84
-
85
- context "when is nil" do
86
- subject { BancoBrasil.new(:agencia => nil) }
87
-
88
- its(:agencia) { should be nil }
89
- end
90
- end
91
-
92
- describe "#conta_corrente" do
93
- context "when have a value" do
94
- subject { BancoBrasil.new(:conta_corrente => 913) }
95
-
96
- its(:conta_corrente) { should eq '00000913' }
97
- end
98
-
99
- context "when is nil" do
100
- subject { BancoBrasil.new(:conta_corrente => nil) }
101
-
102
- its(:conta_corrente) { should be nil }
103
- end
104
- end
105
-
106
- describe "#numero_documento" do
107
- context "when have 'codigo_cedente' 4 digits" do
108
- subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 1234) }
109
-
110
- its(:numero_documento) { should eq '0000913' }
111
- end
112
-
113
- context "when have 'codigo_cedente' 6 digits" do
114
- subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 123456) }
115
-
116
- its(:numero_documento) { should eq '00913' }
117
- end
118
-
119
- context "when have 'codigo_cedente' 7 digits" do
120
- subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 1234567) }
121
-
122
- its(:numero_documento) { should eq '0000000913' }
123
- end
124
-
125
- context "when have 'codigo_cedente' 8 digits" do
126
- subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 12345678) }
127
-
128
- its(:numero_documento) { should eq '000000913' }
129
- end
130
-
131
- context "when is nil" do
132
- subject { BancoBrasil.new(:numero_documento => nil) }
133
-
134
- its(:numero_documento) { should be nil }
135
- end
136
-
137
- context "when 'codigo_cedente' is nil" do
138
- subject { BancoBrasil.new(:numero_documento => '12') }
139
-
140
- its(:numero_documento) { should eq '12' }
141
- end
142
- end
143
-
144
- describe "#codigo_banco" do
145
- its(:codigo_banco) { should eq '001' }
146
- end
147
-
148
- describe "#digito_codigo_banco" do
149
- its(:digito_codigo_banco) { should eq '9' }
150
- end
151
-
152
- describe "#agencia_codigo_cedente" do
153
- subject { BancoBrasil.new(agencia: 9999, digito_agencia: 6, conta_corrente: 99999, digito_conta_corrente: 7) }
154
-
155
- its(:agencia_codigo_cedente) { should eq '9999-6 / 00099999-7' }
156
- end
157
-
158
- describe "#nosso_numero" do
159
- context "when 'codigo_cedente 4 digits" do
160
- subject { BancoBrasil.new(codigo_cedente: 1234, numero_documento: 1984) }
161
-
162
- its(:nosso_numero) { should eq '12340001984-7' }
163
- end
164
-
165
- context "when 'codigo_cedente 6 digits" do
166
- subject { BancoBrasil.new(codigo_cedente: 123456, numero_documento: 1984) }
167
-
168
- its(:nosso_numero) { should eq '12345601984-2' }
169
- end
170
-
171
- context "when 'codigo_cedente 7 digits" do
172
- subject { BancoBrasil.new(codigo_cedente: 1234567, numero_documento: 1984) }
173
-
174
- its(:nosso_numero) { should eq '12345670000001984' }
175
- end
176
-
177
- context "when 'codigo_cedente 8 digits" do
178
- subject { BancoBrasil.new(codigo_cedente: 12345678, numero_documento: 1984) }
179
-
180
- its(:nosso_numero) { should eq '12345678000001984' }
181
- end
182
- end
183
-
184
- describe "#codigo_cedente_quatro_digitos?" do
185
- context "when is true" do
186
- subject { BancoBrasil.new(codigo_cedente: 1234) }
187
-
188
- its(:codigo_cedente_quatro_digitos?) { should be true }
189
- end
190
-
191
- context "when is false" do
192
- subject { BancoBrasil.new(codigo_cedente: 12345) }
193
-
194
- its(:codigo_cedente_quatro_digitos?) { should be false }
195
- end
196
- end
197
-
198
- describe "#codigo_cedente_seis_digitos?" do
199
- context "when is true" do
200
- subject { BancoBrasil.new(codigo_cedente: 123456) }
201
-
202
- its(:codigo_cedente_seis_digitos?) { should be true }
203
- end
204
-
205
- context "when is false" do
206
- subject { BancoBrasil.new(codigo_cedente: 1234567) }
207
-
208
- its(:codigo_cedente_seis_digitos?) { should be false }
209
- end
210
- end
211
-
212
- describe "#codigo_cedente_sete_digitos?" do
213
- context "when is true" do
214
- subject { BancoBrasil.new(codigo_cedente: 1234567) }
215
-
216
- its(:codigo_cedente_sete_digitos?) { should be true }
217
- end
218
-
219
- context "when is false" do
220
- subject { BancoBrasil.new(codigo_cedente: 12345678) }
221
-
222
- its(:codigo_cedente_sete_digitos?) { should be false }
223
- end
224
- end
225
-
226
- describe "#codigo_cedente_oito_digitos?" do
227
- context "when is true" do
228
- subject { BancoBrasil.new(codigo_cedente: 12345678) }
229
-
230
- its(:codigo_cedente_oito_digitos?) { should be true }
231
- end
232
-
233
- context "when is false" do
234
- subject { BancoBrasil.new(codigo_cedente: 123456789) }
235
-
236
- its(:codigo_cedente_oito_digitos?) { should be false }
237
- end
238
- end
239
-
240
- describe "#nosso_numero_dezessete_posicoes?" do
241
- context "when 'carteira' 18, 'numero_documento' 17 digits and 'codigo_cedente' 6 digits" do
242
- subject { BancoBrasil.new(numero_documento: 12345678911234567, carteira: 18, codigo_cedente: 123456) }
243
-
244
- its(:nosso_numero_dezessete_posicoes?) { should be true }
245
- end
246
-
247
- context "when 'carteira' 16, 'numero_documento' 17 digits and 'codigo_cedente' 6 digits" do
248
- subject { BancoBrasil.new(numero_documento: 12345678911234567, carteira: 16, codigo_cedente: 123456) }
249
-
250
- its(:nosso_numero_dezessete_posicoes?) { should be true }
251
- end
252
-
253
- context "when is 'carteira' is not supported" do
254
- subject { BancoBrasil.new(numero_documento: 123456789, carteira: 12, codigo_cedente: 123456) }
255
-
256
- its(:nosso_numero_dezessete_posicoes?) { should be false }
257
- end
258
-
259
- context "when is 'codigo_cedente' is not supported" do
260
- subject { BancoBrasil.new(numero_documento: 123456789, carteira: 16, codigo_cedente: 1234567) }
261
-
262
- its(:nosso_numero_dezessete_posicoes?) { should be false }
263
- end
264
- end
265
-
266
- describe "#codigo_de_barras" do
267
- context "'codigo_cedente' with 4 digits" do
268
- subject do
269
- BancoBrasil.new do |banco_brasil|
270
- banco_brasil.carteira = 18
271
- banco_brasil.valor_documento = 2952.95
272
- banco_brasil.numero_documento = 90801
273
- banco_brasil.agencia = 7123
274
- banco_brasil.digito_agencia = 6
275
- banco_brasil.conta_corrente = 19345
276
- banco_brasil.digito_conta_corrente = 7
277
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
278
- banco_brasil.codigo_cedente = 4321
279
- end
280
- end
281
-
282
- its(:codigo_de_barras) { should eq '00193556100002952954321009080171230001934518' }
283
- its(:linha_digitavel) { should eq '00194.32103 09080.171235 00019.345180 3 55610000295295' }
284
- end
285
-
286
- context "'codigo_cedente' with 6 digits" do
287
- subject do
288
- BancoBrasil.new do |banco_brasil|
289
- banco_brasil.carteira = 18
290
- banco_brasil.valor_documento = 14001.99
291
- banco_brasil.numero_documento = 12901
292
- banco_brasil.agencia = 5030
293
- banco_brasil.digito_agencia = 6
294
- banco_brasil.conta_corrente = 14204195
295
- banco_brasil.digito_conta_corrente = 7
296
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
297
- banco_brasil.codigo_cedente = 555444
298
- end
299
- end
300
-
301
- its(:codigo_de_barras) { should eq '00197556100014001995554441290150301420419518' }
302
- its(:linha_digitavel) { should eq '00195.55440 41290.150303 14204.195185 7 55610001400199' }
303
- end
304
-
305
- context "'codigo_cedente' with 6 digits and 'nosso numero' with 17 digits" do
306
- subject do
307
- BancoBrasil.new do |banco_brasil|
308
- banco_brasil.carteira = 12
309
- banco_brasil.valor_documento = 14001.99
310
- banco_brasil.numero_documento = 12345678911234567
311
- banco_brasil.agencia = 5030
312
- banco_brasil.digito_agencia = 6
313
- banco_brasil.conta_corrente = 14204195
314
- banco_brasil.digito_conta_corrente = 7
315
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
316
- banco_brasil.codigo_cedente = 555444
317
- end
318
- end
319
-
320
- its(:linha_digitavel) { should eq "" }
321
- end
322
-
323
-
324
- context "'codigo_cedente' with 6 digits and 'nosso numero' with 17 digits" do
325
- subject do
326
- BancoBrasil.new do |banco_brasil|
327
- banco_brasil.carteira = 18
328
- banco_brasil.valor_documento = 14001.99
329
- banco_brasil.numero_documento = 12345678911234567
330
- banco_brasil.agencia = 5030
331
- banco_brasil.digito_agencia = 6
332
- banco_brasil.conta_corrente = 14204195
333
- banco_brasil.digito_conta_corrente = 7
334
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
335
- banco_brasil.codigo_cedente = 555444
336
- end
337
- end
338
-
339
- its(:codigo_de_barras) { should eq '00194556100014001995554441234567891123456721' }
340
- its(:linha_digitavel) { should eq "00195.55440 41234.567893 11234.567219 4 55610001400199" }
341
- end
342
-
343
- context "'codigo_cedente' with 7 digits" do
344
- subject do
345
- BancoBrasil.new do |banco_brasil|
346
- banco_brasil.carteira = 18
347
- banco_brasil.valor_documento = 2952.95
348
- banco_brasil.numero_documento = 87654
349
- banco_brasil.agencia = 9999
350
- banco_brasil.digito_agencia = 6
351
- banco_brasil.conta_corrente = 99999
352
- banco_brasil.digito_conta_corrente = 7
353
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
354
- banco_brasil.codigo_cedente = 7777777
355
- end
356
- end
357
-
358
- its(:codigo_de_barras) { should eq '00197556100002952950000007777777000008765418' }
359
- its(:linha_digitavel) { should eq '00190.00009 07777.777009 00087.654182 7 55610000295295' }
360
- end
361
-
362
- context "'codigo_cedente' with 8 digits" do
363
- subject do
364
- BancoBrasil.new do |banco_brasil|
365
- banco_brasil.carteira = 18
366
- banco_brasil.valor_documento = 2952.95
367
- banco_brasil.numero_documento = 87654
368
- banco_brasil.agencia = 9999
369
- banco_brasil.digito_agencia = 6
370
- banco_brasil.conta_corrente = 99999
371
- banco_brasil.digito_conta_corrente = 7
372
- banco_brasil.data_vencimento = Date.parse('2012-12-28')
373
- banco_brasil.codigo_cedente = 77777778
374
- end
375
- end
376
-
377
- its(:codigo_de_barras) { should eq '00191556100002952950000007777777800008765418' }
378
- its(:linha_digitavel) { should eq '00190.00009 07777.777801 00087.654182 1 55610000295295' }
379
- end
380
- end
381
- end
382
- end
383
- end
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- module BoletoBancario
5
- module Core
6
- describe Boleto do
7
- describe '#initialize' do
8
- context 'when passing a Hash' do
9
- subject do
10
- described_class.new(
11
- :numero_documento => '191075',
12
- :valor_documento => 101.99,
13
- :data_vencimento => Date.new(2012, 10, 10),
14
- :carteira => '175',
15
- :agencia => '0098',
16
- :digito_agencia => '1',
17
- :conta_corrente => '98701',
18
- :cedente => 'Nome da razao social',
19
- :sacado => 'Teste',
20
- :documento_sacado => '725.275.005-10',
21
- :endereco_sacado => 'Rua teste, 23045'
22
- )
23
- end
24
-
25
- its(:numero_documento) { should eq '191075' }
26
- its(:valor_documento) { should eq 101.99 }
27
- its(:data_vencimento) { should eq Date.new(2012, 10, 10) }
28
- its(:carteira) { should eq '175' }
29
- its(:agencia) { should eq '0098' }
30
- its(:digito_agencia) { should eq '1' }
31
- its(:conta_corrente) { should eq '98701' }
32
- its(:codigo_moeda) { should eq '9' }
33
- its(:cedente) { should eq 'Nome da razao social' }
34
- its(:especie) { should eq 'R$' }
35
- its(:especie_documento) { should eq 'DM' }
36
- its(:data_documento) { should eq Date.today }
37
- its(:sacado) { should eq 'Teste' }
38
- its(:documento_sacado) { should eq '725.275.005-10' }
39
- its(:endereco_sacado) { should eq 'Rua teste, 23045'}
40
- its(:local_pagamento) { should eq 'PAGÁVEL EM QUALQUER BANCO ATÉ O VENCIMENTO' }
41
- end
42
-
43
- context 'when passing a block' do
44
- subject do
45
- described_class.new do |boleto|
46
- boleto.numero_documento = '187390'
47
- boleto.valor_documento = 1
48
- boleto.data_vencimento = Date.new(2012, 10, 10)
49
- boleto.carteira = '109'
50
- boleto.agencia = '0914'
51
- boleto.conta_corrente = '82369'
52
- boleto.codigo_cedente = '90182'
53
- boleto.endereco_cedente = 'Rua Itapaiuna, 2434'
54
- boleto.cedente = 'Nome da razao social'
55
- boleto.documento_cedente = '62.526.713/0001-40'
56
- boleto.sacado = 'Teste'
57
- end
58
- end
59
-
60
- its(:numero_documento) { should eq '187390' }
61
- its(:valor_documento) { should eq 1 }
62
- its(:carteira) { should eq '109' }
63
- its(:agencia) { should eq '0914' }
64
- its(:conta_corrente) { should eq '82369' }
65
- its(:codigo_moeda) { should eq '9' }
66
- its(:codigo_cedente) { should eq '90182' }
67
- its(:endereco_cedente) { should eq 'Rua Itapaiuna, 2434' }
68
- its(:cedente) { should eq 'Nome da razao social' }
69
- its(:documento_cedente) { should eq '62.526.713/0001-40' }
70
- its(:sacado) { should eq 'Teste' }
71
- end
72
- end
73
-
74
- describe "#carteira_formatada" do
75
- it "should return 'carteira' as default" do
76
- subject.stub(:carteira).and_return('Foo')
77
- subject.carteira_formatada.should eq 'Foo'
78
- end
79
- end
80
-
81
- describe "#codigo_banco" do
82
- it { expect { subject.codigo_banco }.to raise_error(NotImplementedError) }
83
- end
84
-
85
- describe "#digito_codigo_banco" do
86
- it { expect { subject.digito_codigo_banco }.to raise_error(NotImplementedError) }
87
- end
88
-
89
- describe "#agencia_codigo_cedente" do
90
- it { expect { subject.agencia_codigo_cedente }.to raise_error(NotImplementedError) }
91
- end
92
-
93
- describe "#nosso_numero" do
94
- it { expect { subject.nosso_numero }.to raise_error(NotImplementedError) }
95
- end
96
-
97
- describe "#codigo_de_barras_do_banco" do
98
- it { expect { subject.codigo_de_barras_do_banco }.to raise_error(NotImplementedError) }
99
- end
100
- end
101
- end
102
- end
@@ -1,170 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- module BoletoBancario
5
- module Core
6
- describe Bradesco do
7
- it_should_behave_like 'boleto bancario'
8
-
9
- describe "on validations" do
10
- it { should have_valid(:agencia).when('1', '123', '1234') }
11
- it { should_not have_valid(:agencia).when('12345', '123456', '1234567', nil, '') }
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
- it { should have_valid(:conta_corrente).when('1', '123', '1234') }
17
- it { should_not have_valid(:conta_corrente).when('12345678', '123456789', nil, '') }
18
-
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
- it { should have_valid(:numero_documento).when(12345678911, '12345678911', '13') }
26
- it { should_not have_valid(:numero_documento).when('', nil, 123456789112, 1234567891113) }
27
- end
28
-
29
- describe "#agencia" do
30
- context "when have a value" do
31
- subject { Bradesco.new(:agencia => 2) }
32
-
33
- its(:agencia) { should eq '0002' }
34
- end
35
-
36
- context "when is nil" do
37
- its(:agencia) { should be nil }
38
- end
39
- end
40
-
41
- describe "#conta_corrente" do
42
- context "when have a value" do
43
- subject { Bradesco.new(:conta_corrente => 1) }
44
-
45
- its(:conta_corrente) { should eq '0000001' }
46
- end
47
-
48
- context "when is nil" do
49
- its(:conta_corrente) { should be nil }
50
- end
51
- end
52
-
53
- describe "#numero_documento" do
54
- context "when have a value" do
55
- subject { Bradesco.new(:numero_documento => 1234) }
56
-
57
- its(:numero_documento) { should eq '00000001234' }
58
- end
59
-
60
- context "when is nil" do
61
- its(:numero_documento) { should be nil }
62
- end
63
- end
64
-
65
- describe "#carteira" do
66
- context "when have a value" do
67
- subject { Bradesco.new(:carteira => 3) }
68
-
69
- its(:carteira) { should eq '03' }
70
- end
71
-
72
- context "when is nil" do
73
- its(:carteira) { should be nil }
74
- end
75
- end
76
-
77
- describe "#carteira_formatada" do
78
- context "when carteira is '21'" do
79
- subject { Bradesco.new(:carteira => 21) }
80
-
81
- its(:carteira_formatada) { should eq '21 – Cobrança Interna Com Registro' }
82
- end
83
-
84
- context "when carteira is '22'" do
85
- subject { Bradesco.new(:carteira => 22) }
86
-
87
- its(:carteira_formatada) { should eq '22 – Cobrança Interna sem registro' }
88
- end
89
-
90
- context "when carteira is '03'" do
91
- subject { Bradesco.new(:carteira => 3) }
92
-
93
- its(:carteira_formatada) { should eq '03' }
94
- end
95
- end
96
-
97
- describe "#codigo_banco" do
98
- its(:codigo_banco) { should eq '237' }
99
- end
100
-
101
- describe "#digito_codigo_banco" do
102
- its(:digito_codigo_banco) { should eq '2' }
103
- end
104
-
105
- describe "#agencia_codigo_cedente" do
106
- subject { Bradesco.new(agencia: '1172', digito_agencia: '0', conta_corrente: '0403005', digito_conta_corrente: '2') }
107
-
108
- its(:agencia_codigo_cedente) { should eq '1172-0 / 0403005-2'}
109
- end
110
-
111
- describe "#nosso_numero" do
112
- context "documentation example" do
113
- subject { Bradesco.new(:carteira => '19', :numero_documento => '00000000002') }
114
-
115
- its(:nosso_numero) { should eq '19/00000000002-8' }
116
- end
117
-
118
- context "more examples from documentation" do
119
- subject { Bradesco.new(:carteira => '19', :numero_documento => '00000000001') }
120
-
121
- its(:nosso_numero) { should eq '19/00000000001-P' }
122
- end
123
-
124
- context "more examples" do
125
- subject { Bradesco.new(:carteira => '06', :numero_documento => '00075896452') }
126
-
127
- its(:nosso_numero) { should eq '06/00075896452-5' }
128
- end
129
- end
130
-
131
- describe "#codigo_de_barras" do
132
- context "more examples" do
133
- subject do
134
- Bradesco.new do |boleto|
135
- boleto.carteira = 6
136
- boleto.numero_documento = 75896452
137
- boleto.valor_documento = 2952.95
138
- boleto.data_vencimento = Date.parse('2012-12-28')
139
- boleto.agencia = 1172
140
- boleto.digito_agencia = 0
141
- boleto.conta_corrente = 403005
142
- boleto.digito_conta_corrente = 2
143
- end
144
- end
145
-
146
- its(:codigo_de_barras) { should eq '23796556100002952951172060007589645204030050' }
147
- its(:linha_digitavel) { should eq '23791.17209 60007.589645 52040.300502 6 55610000295295' }
148
- end
149
-
150
- context "when carteira '09'" do
151
- subject do
152
- Bradesco.new do |boleto|
153
- boleto.carteira = 9
154
- boleto.numero_documento = 175896451
155
- boleto.valor_documento = 2959.78
156
- boleto.data_vencimento = Date.parse('2012-12-28')
157
- boleto.agencia = 1172
158
- boleto.digito_agencia = 0
159
- boleto.conta_corrente = 403005
160
- boleto.digito_conta_corrente = 2
161
- end
162
- end
163
-
164
- its(:codigo_de_barras) { should eq '23791556100002959781172090017589645104030050' }
165
- its(:linha_digitavel) { should eq '23791.17209 90017.589640 51040.300504 1 55610000295978' }
166
- end
167
- end
168
- end
169
- end
170
- end