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.
- checksums.yaml +7 -0
- data/Changelog.markdown +58 -2
- data/README.markdown +679 -156
- data/lib/boleto_bancario/calculos/documento.rb +191 -0
- data/lib/boleto_bancario/calculos/fator_vencimento.rb +78 -31
- 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 +97 -35
- data/lib/boleto_bancario/core/bradesco.rb +28 -16
- data/lib/boleto_bancario/core/c6_bank.rb +155 -0
- data/lib/boleto_bancario/core/caixa.rb +233 -0
- data/lib/boleto_bancario/core/inter.rb +155 -0
- data/lib/boleto_bancario/core/itau.rb +20 -10
- data/lib/boleto_bancario/core/nubank.rb +156 -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/locales/pt-BR.yml +55 -0
- data/lib/boleto_bancario/renderers/base.rb +154 -0
- data/lib/boleto_bancario/renderers/html_renderer.rb +92 -0
- data/lib/boleto_bancario/renderers/pdf_renderer.rb +130 -0
- data/lib/boleto_bancario/renderers/png_renderer.rb +66 -0
- data/lib/boleto_bancario/templates/_barcode.html.erb +3 -0
- data/lib/boleto_bancario/templates/_cedente.html.erb +14 -0
- data/lib/boleto_bancario/templates/_header.html.erb +4 -0
- data/lib/boleto_bancario/templates/_instructions.html.erb +10 -0
- data/lib/boleto_bancario/templates/_payment.html.erb +36 -0
- data/lib/boleto_bancario/templates/_sacado.html.erb +10 -0
- data/lib/boleto_bancario/templates/boleto.html.erb +22 -0
- data/lib/boleto_bancario/templates/boleto_styles.css +18 -0
- data/lib/boleto_bancario/version.rb +3 -2
- data/lib/boleto_bancario.rb +48 -19
- data/lib/generators/boleto_bancario/views_generator.rb +47 -0
- metadata +140 -106
- data/.gitignore +0 -18
- data/.rspec +0 -1
- data/.rvmrc +0 -1
- data/Gemfile +0 -3
- data/Planning.markdown +0 -131
- data/Rakefile +0 -9
- data/TODO.markdown +0 -5
- data/boleto_bancario.gemspec +0 -25
- data/documentacoes_dos_boletos/Bradesco/Manual_BRADESCO.PDF +0 -0
- data/spec/boleto_bancario/calculos/digitos_spec.rb +0 -19
- data/spec/boleto_bancario/calculos/fator_vencimento_spec.rb +0 -59
- data/spec/boleto_bancario/calculos/fatores_de_multiplicacao_spec.rb +0 -69
- data/spec/boleto_bancario/calculos/linha_digitavel_spec.rb +0 -57
- data/spec/boleto_bancario/calculos/modulo10_spec.rb +0 -49
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a7_spec.rb +0 -43
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_resto_zero_spec.rb +0 -39
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_spec.rb +0 -61
- data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x_spec.rb +0 -37
- data/spec/boleto_bancario/calculos/modulo11_spec.rb +0 -19
- data/spec/boleto_bancario/core/banco_brasil_spec.rb +0 -383
- data/spec/boleto_bancario/core/boleto_spec.rb +0 -102
- data/spec/boleto_bancario/core/bradesco_spec.rb +0 -170
- data/spec/boleto_bancario/core/itau_spec.rb +0 -336
- data/spec/boleto_bancario/core/santander_spec.rb +0 -135
- data/spec/shared_examples/boleto_bancario_shared_example.rb +0 -164
- data/spec/spec_helper.rb +0 -14
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe FatorVencimento do
|
|
6
|
-
describe "#base_date" do
|
|
7
|
-
it "should be 1997-10-07" do
|
|
8
|
-
FatorVencimento.new(Date.parse("2012-02-01")).base_date.should eq Date.new(1997, 10, 7)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#calculate" do
|
|
13
|
-
it 'should return an empty string when passing nil value' do
|
|
14
|
-
FatorVencimento.new(nil).should eq ''
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'should return an empty string when passing empty value' do
|
|
18
|
-
FatorVencimento.new('').should eq ''
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should calculate the days between expiration date and base date" do
|
|
22
|
-
FatorVencimento.new(Date.parse("2012-12-2")).should eq "5535"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should calculate equal to itau documentation example" do
|
|
26
|
-
FatorVencimento.new(Date.parse("2000-07-04")).should eq "1001"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should calculate equal to itau documentation last section of the docs" do
|
|
30
|
-
FatorVencimento.new(Date.parse("2002-05-01")).should eq "1667"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should calculate to the maximum date equal to itau documentation example" do
|
|
34
|
-
FatorVencimento.new(Date.parse("2025-02-21")).should eq "9999"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should calculate the days between expiration date one year ago" do
|
|
38
|
-
FatorVencimento.new(Date.parse("2011-05-25")).should eq "4978"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should calculate the days between expiration date two years ago" do
|
|
42
|
-
FatorVencimento.new(Date.parse("2010-10-02")).should eq "4743"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should calculate the days between expiration date one year from now" do
|
|
46
|
-
FatorVencimento.new(Date.parse("2013-02-01")).should eq "5596"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should calculate the days between expiration date eigth years from now" do
|
|
50
|
-
FatorVencimento.new(Date.parse("2020-02-01")).should eq "8152"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "should calculate the days between expiration date formating with 4 digits" do
|
|
54
|
-
FatorVencimento.new(Date.parse("1997-10-08")).should eq "0001"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe FatoresDeMultiplicacao do
|
|
6
|
-
context 'with factors of 2 and 1' do
|
|
7
|
-
let(:factors) { [2, 1] }
|
|
8
|
-
|
|
9
|
-
context 'with one digit' do
|
|
10
|
-
subject { FatoresDeMultiplicacao.new(1, fatores: factors) }
|
|
11
|
-
|
|
12
|
-
it { should eq [2] }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'with four digits' do
|
|
16
|
-
subject { FatoresDeMultiplicacao.new(1234, fatores: factors) }
|
|
17
|
-
|
|
18
|
-
it { should eq [1, 4, 3, 8] }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context 'with five digits' do
|
|
22
|
-
subject { FatoresDeMultiplicacao.new(11385, fatores: factors) }
|
|
23
|
-
|
|
24
|
-
it { should eq [2, 1, 6, 8, 10] }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'with ten digits' do
|
|
28
|
-
subject { FatoresDeMultiplicacao.new(1234567890, fatores: factors) }
|
|
29
|
-
|
|
30
|
-
it { should eq [1, 4, 3, 8, 5, 12, 7, 16, 9, 0] }
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context 'with factors of 2..9' do
|
|
35
|
-
let(:factors) { (2..9).to_a }
|
|
36
|
-
|
|
37
|
-
context 'with one digit' do
|
|
38
|
-
subject { FatoresDeMultiplicacao.new(4, fatores: factors) }
|
|
39
|
-
|
|
40
|
-
it { should eq [8] }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context 'with four digits' do
|
|
44
|
-
subject { FatoresDeMultiplicacao.new(1864, fatores: factors) }
|
|
45
|
-
|
|
46
|
-
it { should eq [ 5, 32, 18, 8] }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'with ten digits' do
|
|
50
|
-
subject { FatoresDeMultiplicacao.new(1234567890, fatores: factors) }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context 'with bradesco documentation example' do
|
|
54
|
-
let(:bradesco_example) { '9999101200000350007772130530150081897500000' }
|
|
55
|
-
subject { FatoresDeMultiplicacao.new(bradesco_example, fatores: factors) }
|
|
56
|
-
|
|
57
|
-
it { should eq [36, 27, 18, 81, 8, 0, 6, 10, 0, 0, 0, 0, 0, 21, 30, 0, 0, 0, 14, 63, 56, 14, 6, 15, 0, 15, 6, 0, 8, 35, 0, 0, 32, 3, 16, 81, 56, 35, 0, 0, 0, 0, 0] }
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'with itau documentation example' do
|
|
61
|
-
let(:itau_example) { '3419166700000123451101234567880057123457000' }
|
|
62
|
-
subject { FatoresDeMultiplicacao.new(itau_example, fatores: factors) }
|
|
63
|
-
|
|
64
|
-
it { should eq [12, 12, 2, 81, 8, 42, 36, 35, 0, 0, 0, 0, 0, 7, 12, 15, 16, 15, 2, 9, 0, 7, 12, 15, 16, 15, 12, 63, 64, 56, 0, 0, 20, 21, 2, 18, 24, 28, 30, 35, 0, 0, 0] }
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe LinhaDigitavel do
|
|
6
|
-
context "using the Itau documentation example" do
|
|
7
|
-
subject { LinhaDigitavel.new('34196166700000123451091234567880057123457000') }
|
|
8
|
-
|
|
9
|
-
it { should eq '34191.09123 34567.880058 71234.570001 6 16670000012345' }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "using the Bradesco documentation example" do
|
|
13
|
-
subject { LinhaDigitavel.new('99991101200000350007772130530150081897500000') }
|
|
14
|
-
|
|
15
|
-
it { should eq '99997.77213 30530.150082 18975.000003 1 10120000035000' }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "using the HSBC documentation example" do
|
|
19
|
-
subject { LinhaDigitavel.new('39998100100000311551111122222500546666666001') }
|
|
20
|
-
|
|
21
|
-
it { should eq '39991.11119 22222.500542 66666.660015 8 10010000031155' }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "using the Caixa documentation example" do
|
|
25
|
-
subject { LinhaDigitavel.new('10491107400000160000001100128701000901200200') }
|
|
26
|
-
|
|
27
|
-
it { should eq '10490.00118 00128.701000 09012.002003 1 10740000016000' }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "when 'codigo_de_barras' invalid" do
|
|
31
|
-
context "when is empty" do
|
|
32
|
-
subject { LinhaDigitavel.new('') }
|
|
33
|
-
|
|
34
|
-
it { should eq '' }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context "when nil" do
|
|
38
|
-
subject { LinhaDigitavel.new(nil) }
|
|
39
|
-
|
|
40
|
-
it { should eq '' }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when have less than 44 positions" do
|
|
44
|
-
subject { LinhaDigitavel.new('121212121') }
|
|
45
|
-
|
|
46
|
-
it { should eq '' }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "when have more than 44 positions" do
|
|
50
|
-
subject { LinhaDigitavel.new('12345678901234567890123456789012345678901234567890') }
|
|
51
|
-
|
|
52
|
-
it { should eq '' }
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo10 do
|
|
6
|
-
it "should accept the examples by the 'Itau documentation'" do
|
|
7
|
-
Modulo10.new('341911012').should eq '1'
|
|
8
|
-
Modulo10.new('3456788005').should eq '8'
|
|
9
|
-
Modulo10.new('7123457000').should eq '1'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "returns zero when number is 0" do
|
|
13
|
-
Modulo10.new('0').should eq '0'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "returns zero when mod 10 is zero" do
|
|
17
|
-
Modulo10.new('99906').should eq '0'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "calculate when number had 1 digit" do
|
|
21
|
-
Modulo10.new('1').should eq '8'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "calculate when number had 2 digits" do
|
|
25
|
-
Modulo10.new('10').should eq '9'
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "calculate when number had 3 digits" do
|
|
29
|
-
Modulo10.new('994').should eq '4'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "calculate when number had 5 digits" do
|
|
33
|
-
Modulo10.new('97831').should eq '2'
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "calculate when number had 6 digits" do
|
|
37
|
-
Modulo10.new('147966').should eq '6'
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "calculate when number had 10 digits" do
|
|
41
|
-
Modulo10.new('3456788005').should eq '8'
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should accept numbers too" do
|
|
45
|
-
Modulo10.new(12345).should eq '5'
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo11FatorDe2a7 do
|
|
6
|
-
context 'with Bradesco documentation example' do
|
|
7
|
-
subject { Modulo11FatorDe2a7.new('1900000000002') }
|
|
8
|
-
|
|
9
|
-
it { should eq '8' }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context 'with Bradesco example that returns P' do
|
|
13
|
-
subject { Modulo11FatorDe2a7.new('1900000000001') }
|
|
14
|
-
|
|
15
|
-
it { should eq 'P' }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'with Bradesco example that returns zero' do
|
|
19
|
-
subject { Modulo11FatorDe2a7.new('1900000000006') }
|
|
20
|
-
|
|
21
|
-
it { should eq '0' }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "when have two digits" do
|
|
25
|
-
subject { Modulo11FatorDe2a7.new('20') }
|
|
26
|
-
|
|
27
|
-
it { should eq '5' }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when have two digits (more examples)" do
|
|
31
|
-
subject { Modulo11FatorDe2a7.new('26') }
|
|
32
|
-
|
|
33
|
-
it { should eq '4' }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context "more examples" do
|
|
37
|
-
subject { Modulo11FatorDe2a7.new('64') }
|
|
38
|
-
|
|
39
|
-
it { should eq '7' }
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo11FatorDe2a9RestoZero do
|
|
6
|
-
describe "#calculate" do
|
|
7
|
-
context "with a one number digit" do
|
|
8
|
-
subject { Modulo11FatorDe2a9RestoZero.new(6) }
|
|
9
|
-
|
|
10
|
-
it { should eq '0' }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "with a two number digit" do
|
|
14
|
-
subject { Modulo11FatorDe2a9RestoZero.new(100) }
|
|
15
|
-
|
|
16
|
-
it { should eq '7' }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "with a three number digit" do
|
|
20
|
-
subject { Modulo11FatorDe2a9RestoZero.new(1004) }
|
|
21
|
-
|
|
22
|
-
it { should eq '9' }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context "with a three number digit that returns zero" do
|
|
26
|
-
subject { Modulo11FatorDe2a9RestoZero.new(1088) }
|
|
27
|
-
|
|
28
|
-
it { should eq '0' }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when mod division return '10'" do
|
|
32
|
-
subject { Modulo11FatorDe2a9RestoZero.new(1073) }
|
|
33
|
-
|
|
34
|
-
it { should eq '1' }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo11FatorDe2a9 do
|
|
6
|
-
context 'with Itau example' do
|
|
7
|
-
subject { Modulo11FatorDe2a9.new('3419166700000123451101234567880057123457000') }
|
|
8
|
-
|
|
9
|
-
it { should eq '6' }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context 'with Bradesco example' do
|
|
13
|
-
subject { Modulo11FatorDe2a9.new('9999101200000350007772130530150081897500000') }
|
|
14
|
-
|
|
15
|
-
it { should eq '1' }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'with Banco Brasil example' do
|
|
19
|
-
subject { Modulo11FatorDe2a9.new('0019373700000001000500940144816060680935031') }
|
|
20
|
-
|
|
21
|
-
it { should eq '3' }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'with Caixa example' do
|
|
25
|
-
subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901200200') }
|
|
26
|
-
|
|
27
|
-
it { should eq '1' }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context 'when calculations returns 11' do
|
|
31
|
-
subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901200298') }
|
|
32
|
-
|
|
33
|
-
it { should eq '1' }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'when calculations returns 1' do
|
|
37
|
-
subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901244437') }
|
|
38
|
-
|
|
39
|
-
it { should eq '1' }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'with one digit' do
|
|
43
|
-
subject { Modulo11FatorDe2a9.new('1') }
|
|
44
|
-
|
|
45
|
-
it { should eq '9' }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'with two digits' do
|
|
49
|
-
subject { Modulo11FatorDe2a9.new('91') }
|
|
50
|
-
|
|
51
|
-
it { should eq '4' }
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context 'with three digits' do
|
|
55
|
-
subject { Modulo11FatorDe2a9.new('189') }
|
|
56
|
-
|
|
57
|
-
it { should eq '9' }
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo11FatorDe9a2RestoX do
|
|
6
|
-
context "when the mod result is 10 (ten)" do
|
|
7
|
-
subject { Modulo11FatorDe9a2RestoX.new('3973') }
|
|
8
|
-
|
|
9
|
-
it { should eq 'X' }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "when the mod result is zero" do
|
|
13
|
-
subject { Modulo11FatorDe9a2RestoX.new('3995') }
|
|
14
|
-
|
|
15
|
-
it { should eq '0' }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "using the 'Banco Brasil' documentation example" do
|
|
19
|
-
subject { Modulo11FatorDe9a2RestoX.new('01129004590') }
|
|
20
|
-
|
|
21
|
-
it { should eq '3' }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "when the result is one" do
|
|
25
|
-
subject { Modulo11FatorDe9a2RestoX.new('5964') }
|
|
26
|
-
|
|
27
|
-
it { should eq '1' }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "with a five digit number" do
|
|
31
|
-
subject { Modulo11FatorDe9a2RestoX.new('10949') }
|
|
32
|
-
|
|
33
|
-
it { should eq '5' }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Calculos
|
|
5
|
-
describe Modulo11 do
|
|
6
|
-
subject { Modulo11.new(1) }
|
|
7
|
-
|
|
8
|
-
describe "#fatores" do
|
|
9
|
-
before { Modulo11.any_instance.stub(:calculate).and_return(1) }
|
|
10
|
-
|
|
11
|
-
it { expect { subject.fatores }.to raise_error(NotImplementedError, "Not implemented #fatores in subclass.") }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "#calculate" do
|
|
15
|
-
it { expect { Modulo11.new(1) }.to raise_error(NotImplementedError, "Not implemented #calculate in subclass.") }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|