kivanio-brcobranca 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +5 -1
  2. data/Manifest.txt +24 -0
  3. data/PostInstall.txt +4 -0
  4. data/README.rdoc +4 -4
  5. data/Rakefile +9 -6
  6. data/brcobranca.gemspec +9 -9
  7. data/lib/brcobranca.rb +10 -2
  8. data/lib/brcobranca/arquivos/logos/banespa.jpg +0 -0
  9. data/lib/brcobranca/boleto/banco_banespa.rb +85 -0
  10. data/lib/brcobranca/boleto/banco_bradesco.rb +14 -1
  11. data/lib/brcobranca/boleto/banco_brasil.rb +18 -9
  12. data/lib/brcobranca/boleto/banco_hsbc.rb +22 -8
  13. data/lib/brcobranca/boleto/banco_itau.rb +20 -10
  14. data/lib/brcobranca/boleto/banco_real.rb +16 -2
  15. data/lib/brcobranca/boleto/banco_unibanco.rb +19 -5
  16. data/lib/brcobranca/boleto/base.rb +21 -15
  17. data/lib/brcobranca/boleto/template/rghost.rb +18 -16
  18. data/lib/brcobranca/boleto/template/util.rb +2 -0
  19. data/lib/brcobranca/core_ext.rb +57 -47
  20. data/lib/brcobranca/currency.rb +7 -10
  21. data/spec/arquivos/CBR64310.RET +28 -0
  22. data/spec/brcobranca/banco_banespa_spec.rb +195 -0
  23. data/spec/brcobranca/banco_bradesco_spec.rb +179 -0
  24. data/spec/brcobranca/banco_brasil_spec.rb +353 -0
  25. data/spec/brcobranca/banco_hsbc_spec.rb +216 -0
  26. data/spec/brcobranca/banco_itau_spec.rb +202 -0
  27. data/spec/brcobranca/banco_real_spec.rb +145 -0
  28. data/spec/brcobranca/banco_unibanco_spec.rb +193 -0
  29. data/spec/brcobranca/base_spec.rb +240 -0
  30. data/spec/brcobranca/core_ext_spec.rb +275 -0
  31. data/spec/brcobranca/currency_spec.rb +81 -0
  32. data/spec/brcobranca/retorno_cbr643_spec.rb +69 -0
  33. data/spec/brcobranca/rghost_spec.rb +36 -0
  34. data/spec/brcobranca/template/rghost_spec.rb +65 -0
  35. data/spec/brcobranca/template/util_spec.rb +42 -0
  36. data/spec/brcobranca_spec.rb +8 -0
  37. data/spec/rcov.opts +2 -0
  38. data/spec/spec.opts +6 -0
  39. data/spec/spec_helper.rb +10 -0
  40. data/tasks/rcov.rake +12 -0
  41. data/tasks/rspec.rake +21 -0
  42. metadata +34 -31
  43. data/test/test_banco_bradesco.rb +0 -87
  44. data/test/test_banco_brasil.rb +0 -276
  45. data/test/test_banco_hsbc.rb +0 -81
  46. data/test/test_banco_itau.rb +0 -103
  47. data/test/test_banco_real.rb +0 -112
  48. data/test/test_banco_unibanco.rb +0 -92
  49. data/test/test_base.rb +0 -162
  50. data/test/test_core_ext.rb +0 -227
  51. data/test/test_currency.rb +0 -51
  52. data/test/test_helper.rb +0 -5
  53. data/test/test_retorno_cbr643.rb +0 -66
  54. data/test/test_rghost.rb +0 -49
@@ -1,112 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoReal < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto_novo = BancoReal.new
7
- @boleto_novo.cedente = "Kivanio Barbosa"
8
- @boleto_novo.documento_cedente = "12345678912"
9
- @boleto_novo.sacado = "Claudio Pozzebom"
10
- @boleto_novo.sacado_documento = "12345678900"
11
- @boleto_novo.aceite = "S"
12
- @boleto_novo.agencia = "4042"
13
- @boleto_novo.conta_corrente = "61900"
14
- end
15
-
16
- def boleto_carteira_registrada
17
- @boleto_novo.banco = "356"
18
- @boleto_novo.agencia = "4042"
19
- @boleto_novo.conta_corrente = "61900"
20
- @boleto_novo.carteira = "56"
21
- @boleto_novo.moeda = "9"
22
- @boleto_novo.valor = 135.00
23
- @boleto_novo.numero_documento = "7701684"
24
- @boleto_novo.data_documento = Date.parse("2008-02-01")
25
- @boleto_novo.dias_vencimento = 0
26
- end
27
-
28
- def boleto_carteira_sem_registro
29
- @boleto_novo.banco = "356"
30
- @boleto_novo.agencia = "4042"
31
- @boleto_novo.conta_corrente = "61900"
32
- @boleto_novo.carteira = "57"
33
- @boleto_novo.moeda = "9"
34
- @boleto_novo.valor = 135.00
35
- @boleto_novo.numero_documento = "777700168"
36
- @boleto_novo.data_documento = Date.parse("2008-02-01")
37
- @boleto_novo.dias_vencimento = 1
38
- end
39
-
40
- def boleto_carteira_sem_registro_2
41
- @boleto_novo.banco = "356"
42
- @boleto_novo.agencia = "1018"
43
- @boleto_novo.conta_corrente = "0016324"
44
- @boleto_novo.carteira = "57"
45
- @boleto_novo.moeda = "9"
46
- @boleto_novo.valor = 934.23
47
- @boleto_novo.numero_documento = "00005020"
48
- @boleto_novo.data_documento = Date.parse("2004-09-03")
49
- @boleto_novo.dias_vencimento = 0
50
- end
51
-
52
- def boleto_nil
53
- @boleto_novo.banco = ""
54
- @boleto_novo.carteira = ""
55
- @boleto_novo.moeda = ""
56
- @boleto_novo.valor = 0
57
- @boleto_novo.convenio = ""
58
- @boleto_novo.numero_documento = ""
59
- @boleto_novo.data_documento = Date.parse("2008-02-01")
60
- @boleto_novo.dias_vencimento = 0
61
- end
62
-
63
- def test_should_initialize_correctly
64
- assert_equal '356', @boleto_novo.banco
65
- assert_equal '57', @boleto_novo.carteira
66
- assert_equal "DM", @boleto_novo.especie_documento
67
- assert_equal "R$", @boleto_novo.especie
68
- assert_equal "9", @boleto_novo.moeda
69
- assert_equal Date.today, @boleto_novo.data_documento
70
- assert_equal 1, @boleto_novo.dias_vencimento
71
- assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
72
- assert_equal "S", @boleto_novo.aceite
73
- assert_equal 1, @boleto_novo.quantidade
74
- assert_equal 0.0, @boleto_novo.valor
75
- assert_equal 0.0, @boleto_novo.valor_documento
76
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
77
- end
78
-
79
- def test_should_mont_correct_codigo_barras
80
- boleto_carteira_sem_registro
81
- assert_equal "3569377000000135004042006190030000777700168", @boleto_novo.monta_codigo_43_digitos
82
- assert_equal "35692377000000135004042006190030000777700168", @boleto_novo.codigo_barras
83
- boleto_carteira_sem_registro_2
84
- assert_equal "3569252300000934231018001632490000000005020", @boleto_novo.monta_codigo_43_digitos
85
- assert_equal "35697252300000934231018001632490000000005020", @boleto_novo.codigo_barras
86
- boleto_carteira_registrada
87
- assert_equal "3569376900000135000000004042006190087701684", @boleto_novo.monta_codigo_43_digitos
88
- assert_equal "35691376900000135000000004042006190087701684", @boleto_novo.codigo_barras
89
- boleto_nil
90
- assert_equal nil, @boleto_novo.codigo_barras
91
- assert_raise RuntimeError do
92
- boleto_nil
93
- raise 'Verifique as informações do boleto!!!'
94
- end
95
- end
96
-
97
- def test_should_mont_correct_linha_digitalvel
98
- boleto_carteira_registrada
99
- assert_equal("35690.00007 04042.006199 00877.016840 1 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
100
- boleto_carteira_sem_registro
101
- assert_equal("35694.04209 06190.030004 07777.001681 2 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
102
- boleto_carteira_sem_registro_2
103
- assert_equal("35691.01805 01632.490007 00000.050203 7 25230000093423", @boleto_novo.codigo_barras.linha_digitavel)
104
- end
105
-
106
- def test_should_return_agencia_conta_corrente_nosso_numero_dv
107
- boleto_carteira_registrada
108
- assert_equal 8, @boleto_novo.agencia_conta_corrente_nosso_numero_dv
109
- boleto_carteira_sem_registro
110
- assert_equal 3, @boleto_novo.agencia_conta_corrente_nosso_numero_dv
111
- end
112
- end
@@ -1,92 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoUnibanco < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto_novo = BancoUnibanco.new
7
- @boleto_novo.cedente = "Kivanio Barbosa"
8
- @boleto_novo.documento_cedente = "12345678912"
9
- @boleto_novo.sacado = "Claudio Pozzebom"
10
- @boleto_novo.sacado_documento = "12345678900"
11
- @boleto_novo.aceite = "S"
12
- @boleto_novo.agencia = "4042"
13
- @boleto_novo.conta_corrente = "61900"
14
- end
15
-
16
- def boleto_com_registro
17
- @boleto_novo.agencia = "0123"
18
- @boleto_novo.conta_corrente = "100618"
19
- @boleto_novo.carteira = "4"
20
- @boleto_novo.convenio = 2031671
21
- @boleto_novo.valor = 2952.95
22
- @boleto_novo.numero_documento = "1803029901"
23
- @boleto_novo.data_documento = Date.parse("2009-04-30")
24
- @boleto_novo.dias_vencimento = 0
25
- end
26
-
27
- def boleto_sem_registro
28
- @boleto_novo.agencia = "0123"
29
- @boleto_novo.conta_corrente = "100618"
30
- @boleto_novo.carteira = "5"
31
- @boleto_novo.convenio = 2031671
32
- @boleto_novo.valor = 2952.95
33
- @boleto_novo.numero_documento = "1803029901"
34
- @boleto_novo.data_documento = Date.parse("2009-04-30")
35
- @boleto_novo.dias_vencimento = 0
36
- end
37
-
38
- def boleto_nil
39
- @boleto_novo.banco = ""
40
- @boleto_novo.carteira = ""
41
- @boleto_novo.moeda = ""
42
- @boleto_novo.valor = 0
43
- @boleto_novo.convenio = ""
44
- @boleto_novo.numero_documento = ""
45
- @boleto_novo.data_documento = Date.parse("2008-02-01")
46
- @boleto_novo.dias_vencimento = 0
47
- end
48
-
49
- def test_should_initialize_correctly
50
- assert_equal '409', @boleto_novo.banco
51
- assert_equal '5', @boleto_novo.carteira
52
- assert_equal "DM", @boleto_novo.especie_documento
53
- assert_equal "R$", @boleto_novo.especie
54
- assert_equal "9", @boleto_novo.moeda
55
- assert_equal Date.today, @boleto_novo.data_documento
56
- assert_equal 1, @boleto_novo.dias_vencimento
57
- assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
58
- assert_equal "S", @boleto_novo.aceite
59
- assert_equal 1, @boleto_novo.quantidade
60
- assert_equal 0.0, @boleto_novo.valor
61
- assert_equal 0.0, @boleto_novo.valor_documento
62
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
63
- end
64
-
65
- def return_correct_nosso_numero_dv
66
- @boleto_novo.numero_documento = "00001803029901"
67
- assert_equal "5", @boleto_novo.nosso_numero_dv
68
- end
69
-
70
- def test_should_mont_correct_codigo_barras
71
- boleto_sem_registro
72
- assert_equal "4099422300002952955203167100000018030299015", @boleto_novo.monta_codigo_43_digitos
73
- assert_equal "40995422300002952955203167100000018030299015", @boleto_novo.codigo_barras
74
- boleto_com_registro
75
- assert_equal "4099422300002952950409043001236018030299015", @boleto_novo.monta_codigo_43_digitos
76
- assert_equal "40997422300002952950409043001236018030299015", @boleto_novo.codigo_barras
77
- boleto_nil
78
- assert_equal nil, @boleto_novo.codigo_barras
79
- assert_raise RuntimeError do
80
- boleto_nil
81
- raise 'Verifique as informações do boleto!!!'
82
- end
83
- end
84
-
85
- def test_should_mont_correct_linha_digitalvel
86
- boleto_sem_registro
87
- assert_equal("40995.20316 67100.000016 80302.990157 5 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
88
- boleto_com_registro
89
- assert_equal("40990.40901 43001.236017 80302.990157 7 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
90
- end
91
-
92
- end
data/test/test_base.rb DELETED
@@ -1,162 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBase < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto = Brcobranca::Boleto::Base.new
7
- end
8
-
9
- def test_should_initialize_correctly
10
- assert_equal "DM", @boleto.especie_documento
11
- assert_equal "R$", @boleto.especie
12
- assert_equal "9", @boleto.moeda
13
- assert_equal Date.today, @boleto.data_documento
14
- assert_equal 1, @boleto.dias_vencimento
15
- assert_equal((Date.today + 1), @boleto.data_vencimento)
16
- assert_equal "S", @boleto.aceite
17
- assert_equal 1, @boleto.quantidade
18
- assert_equal 0.0, @boleto.valor
19
- assert_equal 0.0, @boleto.valor_documento
20
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto.local_pagamento
21
- end
22
-
23
- def test_should_calculate_correct_banco_dv
24
- @boleto.banco = "85068014982"
25
- assert_equal 9, @boleto.banco_dv
26
- @boleto.banco = "05009401448"
27
- assert_equal 1, @boleto.banco_dv
28
- @boleto.banco = "12387987777700168"
29
- assert_equal 2, @boleto.banco_dv
30
- @boleto.banco = "4042"
31
- assert_equal 8, @boleto.banco_dv
32
- @boleto.banco = "61900"
33
- assert_equal 0, @boleto.banco_dv
34
- @boleto.banco = "0719"
35
- assert_equal 6, @boleto.banco_dv
36
- @boleto.banco = 85068014982
37
- assert_equal 9, @boleto.banco_dv
38
- @boleto.banco = 5009401448
39
- assert_equal 1, @boleto.banco_dv
40
- @boleto.banco = 12387987777700168
41
- assert_equal 2, @boleto.banco_dv
42
- @boleto.banco = 4042
43
- assert_equal 8, @boleto.banco_dv
44
- @boleto.banco = 61900
45
- assert_equal 0, @boleto.banco_dv
46
- @boleto.banco = 719
47
- assert_equal 6, @boleto.banco_dv
48
- end
49
-
50
- def test_should_calculate_correct_agencia_dv
51
- @boleto.agencia = "85068014982"
52
- assert_equal 9, @boleto.agencia_dv
53
- @boleto.agencia = "05009401448"
54
- assert_equal 1, @boleto.agencia_dv
55
- @boleto.agencia = "12387987777700168"
56
- assert_equal 2, @boleto.agencia_dv
57
- @boleto.agencia = "4042"
58
- assert_equal 8, @boleto.agencia_dv
59
- @boleto.agencia = "61900"
60
- assert_equal 0, @boleto.agencia_dv
61
- @boleto.agencia = "0719"
62
- assert_equal 6, @boleto.agencia_dv
63
- @boleto.agencia = 85068014982
64
- assert_equal 9, @boleto.agencia_dv
65
- @boleto.agencia = 5009401448
66
- assert_equal 1, @boleto.agencia_dv
67
- @boleto.agencia = 12387987777700168
68
- assert_equal 2, @boleto.agencia_dv
69
- @boleto.agencia = 4042
70
- assert_equal 8, @boleto.agencia_dv
71
- @boleto.agencia = 61900
72
- assert_equal 0, @boleto.agencia_dv
73
- @boleto.agencia = 719
74
- assert_equal 6, @boleto.agencia_dv
75
- end
76
-
77
- def test_should_calculate_correct_conta_corrente_dv
78
- @boleto.conta_corrente = "85068014982"
79
- assert_equal 9, @boleto.conta_corrente_dv
80
- @boleto.conta_corrente = "05009401448"
81
- assert_equal 1, @boleto.conta_corrente_dv
82
- @boleto.conta_corrente = "12387987777700168"
83
- assert_equal 2, @boleto.conta_corrente_dv
84
- @boleto.conta_corrente = "4042"
85
- assert_equal 8, @boleto.conta_corrente_dv
86
- @boleto.conta_corrente = "61900"
87
- assert_equal 0, @boleto.conta_corrente_dv
88
- @boleto.conta_corrente = "0719"
89
- assert_equal 6, @boleto.conta_corrente_dv
90
- @boleto.conta_corrente = 85068014982
91
- assert_equal 9, @boleto.conta_corrente_dv
92
- @boleto.conta_corrente = 5009401448
93
- assert_equal 1, @boleto.conta_corrente_dv
94
- @boleto.conta_corrente = 12387987777700168
95
- assert_equal 2, @boleto.conta_corrente_dv
96
- @boleto.conta_corrente = 4042
97
- assert_equal 8, @boleto.conta_corrente_dv
98
- @boleto.conta_corrente = 61900
99
- assert_equal 0, @boleto.conta_corrente_dv
100
- @boleto.conta_corrente = 719
101
- assert_equal 6, @boleto.conta_corrente_dv
102
- end
103
-
104
- def test_should_calculate_correct_nosso_numero_dv
105
- @boleto.numero_documento = "85068014982"
106
- assert_equal 9, @boleto.nosso_numero_dv
107
- @boleto.numero_documento = "05009401448"
108
- assert_equal 1, @boleto.nosso_numero_dv
109
- @boleto.numero_documento = "12387987777700168"
110
- assert_equal 2, @boleto.nosso_numero_dv
111
- @boleto.numero_documento = "4042"
112
- assert_equal 8, @boleto.nosso_numero_dv
113
- @boleto.numero_documento = "61900"
114
- assert_equal 0, @boleto.nosso_numero_dv
115
- @boleto.numero_documento = "0719"
116
- assert_equal 6, @boleto.nosso_numero_dv
117
- @boleto.numero_documento = 85068014982
118
- assert_equal 9, @boleto.nosso_numero_dv
119
- @boleto.numero_documento = 5009401448
120
- assert_equal 1, @boleto.nosso_numero_dv
121
- @boleto.numero_documento = 12387987777700168
122
- assert_equal 2, @boleto.nosso_numero_dv
123
- @boleto.numero_documento = 4042
124
- assert_equal 8, @boleto.nosso_numero_dv
125
- @boleto.numero_documento = 61900
126
- assert_equal 0, @boleto.nosso_numero_dv
127
- @boleto.numero_documento = 719
128
- assert_equal 6, @boleto.nosso_numero_dv
129
- end
130
-
131
- def test_should_return_correct_valor_documento
132
- @boleto.quantidade = 1
133
- @boleto.valor = 1
134
- assert_equal 1, @boleto.valor_documento
135
- @boleto.quantidade = 1
136
- @boleto.valor = 1.0
137
- assert_equal 1.0, @boleto.valor_documento
138
- @boleto.quantidade = 1
139
- @boleto.valor = 1.2
140
- assert_equal 1.2, @boleto.valor_documento
141
- @boleto.quantidade = 100
142
- @boleto.valor = 1
143
- assert_equal 100, @boleto.valor_documento
144
- @boleto.quantidade = 1
145
- @boleto.valor = 135.43
146
- assert_equal 135.43, @boleto.valor_documento
147
- end
148
-
149
- def test_should_return_correct_data_vencimento
150
- @boleto.data_documento = Date.parse "2008-02-01"
151
- @boleto.dias_vencimento = 1
152
- assert_equal "2008-02-02", @boleto.data_vencimento.to_s
153
- @boleto.data_documento = Date.parse "2008-02-02"
154
- @boleto.dias_vencimento = 28
155
- assert_equal "2008-03-01", @boleto.data_vencimento.to_s
156
- @boleto.data_documento = Date.parse "2008-02-06"
157
- @boleto.dias_vencimento = 100
158
- assert_equal "2008-05-16", @boleto.data_vencimento.to_s
159
- assert_equal Date.parse("2008-05-16"), @boleto.data_vencimento
160
- end
161
-
162
- end
@@ -1,227 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestCoreExt < Test::Unit::TestCase #:nodoc:[all]
4
- # Teste da Extensão de core do Brcobranca
5
- def test_should_format_correct_cpf
6
- assert_equal "987.892.987-90", 98789298790.to_br_cpf
7
- assert_equal "987.892.987-90", "98789298790".to_br_cpf
8
- end
9
-
10
- def test_should_format_correct_cep
11
- assert_equal "85253-100", 85253100.to_br_cep
12
- assert_equal "85253-100", "85253100".to_br_cep
13
- end
14
-
15
- def test_should_format_correct_cnpj
16
- assert_equal "88.394.510/0001-03", 88394510000103.to_br_cnpj
17
- assert_equal "88.394.510/0001-03", "88394510000103".to_br_cnpj
18
- end
19
-
20
- def test_should_return_correct_object_formated
21
- assert_equal "987.892.987-90", 98789298790.formata_documento
22
- assert_equal "987.892.987-90", "98789298790".formata_documento
23
- assert_equal "85253-100", 85253100.formata_documento
24
- assert_equal "85253-100", "85253100".formata_documento
25
- assert_equal "88.394.510/0001-03", 88394510000103.formata_documento
26
- assert_equal "88.394.510/0001-03", "88394510000103".formata_documento
27
- end
28
-
29
- def test_should_return_true_is_moeda
30
- assert_equal true, 1234.03.to_s.moeda?
31
- assert_equal true, +1234.03.to_s.moeda?
32
- assert_equal true, -1234.03.to_s.moeda?
33
- assert_equal false, 123403.to_s.moeda?
34
- assert_equal false, -123403.to_s.moeda?
35
- assert_equal false, +123403.to_s.moeda?
36
- assert_equal true, "1234.03".moeda?
37
- assert_equal true, "1234,03".moeda?
38
- assert_equal true, "1,234.03".moeda?
39
- assert_equal true, "1.234.03".moeda?
40
- assert_equal true, "1,234,03".moeda?
41
- assert_equal true, "12.340,03".moeda?
42
- assert_equal true, "+1234.03".moeda?
43
- assert_equal true, "+1234,03".moeda?
44
- assert_equal true, "+1,234.03".moeda?
45
- assert_equal true, "+1.234.03".moeda?
46
- assert_equal true, "+1,234,03".moeda?
47
- assert_equal true, "+12.340,03".moeda?
48
- assert_equal true, "-1234.03".moeda?
49
- assert_equal true, "-1234,03".moeda?
50
- assert_equal true, "-1,234.03".moeda?
51
- assert_equal true, "-1.234.03".moeda?
52
- assert_equal true, "-1,234,03".moeda?
53
- assert_equal true, "-12.340,03".moeda?
54
- assert_equal false, "1234ab".moeda?
55
- assert_equal false, "ab1213".moeda?
56
- assert_equal false, "ffab".moeda?
57
- assert_equal false, "1234".moeda?
58
- end
59
-
60
- def test_should_return_correct_number_days
61
- assert_equal 3769, (Date.parse "2008-02-01").fator_vencimento
62
- assert_equal 3770, (Date.parse "2008-02-02").fator_vencimento
63
- assert_equal 3774, (Date.parse "2008-02-06").fator_vencimento
64
- end
65
-
66
- def test_should_return_correct_formated_date
67
- assert_equal "01/02/2008", (Date.parse "2008-02-01").to_s_br
68
- assert_equal "02/02/2008", (Date.parse "2008-02-02").to_s_br
69
- assert_equal "06/02/2008", (Date.parse "2008-02-06").to_s_br
70
- end
71
-
72
- def test_should_clean_value
73
- assert_equal "123403", 1234.03.limpa_valor_moeda
74
- assert_equal "123403", +1234.03.limpa_valor_moeda
75
- assert_equal "123403", -1234.03.limpa_valor_moeda
76
- assert_equal 123403, 123403.limpa_valor_moeda
77
- assert_equal(-123403, -123403.limpa_valor_moeda)
78
- assert_equal(+123403, +123403.limpa_valor_moeda)
79
- assert_equal "123403", "1234.03".limpa_valor_moeda
80
- assert_equal "123403", "1234,03".limpa_valor_moeda
81
- assert_equal "123403", "1,234.03".limpa_valor_moeda
82
- assert_equal "123403", "1.234.03".limpa_valor_moeda
83
- assert_equal "123403", "1,234,03".limpa_valor_moeda
84
- assert_equal "1234003", "12.340,03".limpa_valor_moeda
85
- assert_equal "123403", "+1234.03".limpa_valor_moeda
86
- assert_equal "123403", "+1234,03".limpa_valor_moeda
87
- assert_equal "123403", "+1,234.03".limpa_valor_moeda
88
- assert_equal "123403", "+1.234.03".limpa_valor_moeda
89
- assert_equal "123403", "+1,234,03".limpa_valor_moeda
90
- assert_equal "1234003", "+12.340,03".limpa_valor_moeda
91
- assert_equal "123403", "-1234.03".limpa_valor_moeda
92
- assert_equal "123403", "-1234,03".limpa_valor_moeda
93
- assert_equal "123403", "-1,234.03".limpa_valor_moeda
94
- assert_equal "123403", "-1.234.03".limpa_valor_moeda
95
- assert_equal "123403", "-1,234,03".limpa_valor_moeda
96
- assert_equal "1234003", "-12.340,03".limpa_valor_moeda
97
- assert_equal "1234ab", "1234ab".limpa_valor_moeda
98
- assert_equal "ab1213", "ab1213".limpa_valor_moeda
99
- assert_equal "ffab", "ffab".limpa_valor_moeda
100
- assert_equal "1234", "1234".limpa_valor_moeda
101
- end
102
-
103
- def test_should_calculate_correct_module10
104
- assert_equal nil, " ".modulo10
105
- assert_equal nil, "".modulo10
106
- assert_equal 5, "001905009".modulo10
107
- assert_equal 9, "4014481606".modulo10
108
- assert_equal 4, "0680935031".modulo10
109
- assert_equal 5, "29004590".modulo10
110
- assert_equal 1, "341911012".modulo10
111
- assert_equal 8, "3456788005".modulo10
112
- assert_equal 1, "7123457000".modulo10
113
- assert_equal 8, "00571234511012345678".modulo10
114
- assert_kind_of( Fixnum, "001905009".modulo10 )
115
- assert_equal 0, 0.modulo10
116
- assert_equal 5, 1905009.modulo10
117
- assert_equal 9, 4014481606.modulo10
118
- assert_equal 4, 680935031.modulo10
119
- assert_equal 5, 29004590.modulo10
120
- assert_kind_of( Fixnum, 1905009.modulo10 )
121
- end
122
-
123
- def test_should_calculate_correct_modulo11_9to2
124
- assert_equal 9, "85068014982".modulo11_9to2
125
- assert_equal 1, "05009401448".modulo11_9to2
126
- assert_equal 2, "12387987777700168".modulo11_9to2
127
- assert_equal 8, "4042".modulo11_9to2
128
- assert_equal 0, "61900".modulo11_9to2
129
- assert_equal 6, "0719".modulo11_9to2
130
- assert_equal 5, "000000005444".modulo11_9to2
131
- assert_equal 5, "5444".modulo11_9to2
132
- assert_equal 3, "01129004590".modulo11_9to2
133
- assert_equal 10, "15735".modulo11_9to2
134
- assert_equal 0, "777700168".modulo11_9to2
135
- assert_equal 3, "77700168".modulo11_9to2
136
- assert_equal 2, "00015448".modulo11_9to2
137
- assert_equal 2, "15448".modulo11_9to2
138
- assert_equal 9, "12345678".modulo11_9to2
139
- assert_equal 0, "34230".modulo11_9to2
140
- assert_equal 3, "258281".modulo11_9to2
141
- assert_kind_of( Fixnum, "5444".modulo11_9to2 )
142
- assert_kind_of( Fixnum, "000000005444".modulo11_9to2 )
143
- assert_equal 9, 85068014982.modulo11_9to2
144
- assert_equal 1, 5009401448.modulo11_9to2
145
- assert_equal 2, 12387987777700168.modulo11_9to2
146
- assert_equal 8, 4042.modulo11_9to2
147
- assert_equal 0, 61900.modulo11_9to2
148
- assert_equal 6, 719.modulo11_9to2
149
- assert_equal 5, 5444.modulo11_9to2
150
- assert_equal 3, 1129004590.modulo11_9to2
151
- assert_kind_of( Fixnum, 5444.modulo11_9to2 )
152
- end
153
-
154
- def test_should_calculate_correct_modulo11_9to2_10_como_x
155
- assert_equal 9, "85068014982".modulo11_9to2_10_como_x
156
- assert_equal 1, "05009401448".modulo11_9to2_10_como_x
157
- assert_equal 2, "12387987777700168".modulo11_9to2_10_como_x
158
- assert_equal 8, "4042".modulo11_9to2_10_como_x
159
- assert_equal 0, "61900".modulo11_9to2_10_como_x
160
- assert_equal 6, "0719".modulo11_9to2_10_como_x
161
- assert_equal 5, "000000005444".modulo11_9to2_10_como_x
162
- assert_equal 5, "5444".modulo11_9to2_10_como_x
163
- assert_equal 3, "01129004590".modulo11_9to2_10_como_x
164
- assert_equal "X", "15735".modulo11_9to2_10_como_x
165
- assert_kind_of( String, "15735".modulo11_9to2_10_como_x )
166
- assert_kind_of( Fixnum, "5444".modulo11_9to2_10_como_x )
167
- assert_kind_of( Fixnum, "000000005444".modulo11_9to2_10_como_x )
168
- end
169
-
170
- def test_should_calculate_correct_modulo11_2to9
171
- assert_equal 3, "0019373700000001000500940144816060680935031".modulo11_2to9
172
- assert_kind_of( Fixnum, "0019373700000001000500940144816060680935031".modulo11_2to9 )
173
- assert_equal 6, "3419166700000123451101234567880057123457000".modulo11_2to9
174
- assert_equal 3, 19373700000001000500940144816060680935031.modulo11_2to9
175
- assert_kind_of( Fixnum, 19373700000001000500940144816060680935031.modulo11_2to9 )
176
- end
177
-
178
- def test_should_calculate_correct_addiction_of_numbers
179
- assert_equal 3, 111.soma_digitos
180
- assert_equal 8, 8.soma_digitos
181
- assert_equal 3, "111".soma_digitos
182
- assert_equal 8, "8".soma_digitos
183
- assert_kind_of( Fixnum, 111.soma_digitos )
184
- assert_kind_of( Fixnum, "111".soma_digitos )
185
- end
186
-
187
- def test_should_fill_correctly_with_zeros
188
- assert_equal "123", "123".zeros_esquerda(:tamanho => 0)
189
- assert_equal "123", "123".zeros_esquerda(:tamanho => 1)
190
- assert_equal "123", "123".zeros_esquerda(:tamanho => 2)
191
- assert_equal "123", "123".zeros_esquerda(:tamanho => 3)
192
- assert_equal "0123", "123".zeros_esquerda(:tamanho => 4)
193
- assert_equal "00123", "123".zeros_esquerda(:tamanho => 5)
194
- assert_equal "0000000123", "123".zeros_esquerda(:tamanho => 10)
195
- assert_kind_of( String, "123".zeros_esquerda(:tamanho => 5) )
196
- assert_equal "123", 123.zeros_esquerda(:tamanho => 0)
197
- assert_equal "123", 123.zeros_esquerda(:tamanho => 1)
198
- assert_equal "123", 123.zeros_esquerda(:tamanho => 2)
199
- assert_equal "123", 123.zeros_esquerda(:tamanho => 3)
200
- assert_equal "0123", 123.zeros_esquerda(:tamanho => 4)
201
- assert_equal "00123", 123.zeros_esquerda(:tamanho => 5)
202
- assert_equal "0000000123", 123.zeros_esquerda(:tamanho => 10)
203
- assert_kind_of( String, 123.zeros_esquerda(:tamanho => 5) )
204
- assert_equal "123", "123".zeros_esquerda
205
- assert_equal "123", 123.zeros_esquerda
206
- end
207
-
208
- def test_should_mont_correct_linha_digitalvel
209
- assert_equal("00190.00009 01238.798779 77700.168188 2 37690000013500", "00192376900000135000000001238798777770016818".linha_digitavel)
210
- assert_kind_of(String, "00192376900000135000000001238798777770016818".linha_digitavel)
211
- assert_equal nil, "".linha_digitavel
212
- assert_equal nil, "00193373700".linha_digitavel
213
- assert_equal nil, "0019337370000193373700".linha_digitavel
214
- assert_equal nil, "00b193373700bb00193373700".linha_digitavel
215
- assert_equal nil, "0019337370000193373700bbb".linha_digitavel
216
- assert_equal nil, "0019237690000c135000c0000123f7987e7773016813".linha_digitavel
217
- end
218
-
219
- def test_should_return_correct_julian_date
220
- assert_equal "0429", (Date.parse "2009-02-11").to_juliano
221
- assert_equal "0428", (Date.parse "2008-02-11").to_juliano
222
- assert_equal "0989", (Date.parse "2009-04-08").to_juliano
223
- # Ano 2008 eh bisexto
224
- assert_equal "0998", (Date.parse "2008-04-08").to_juliano
225
- end
226
-
227
- end