cnab 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
1
  module Cnab
2
2
  module Helper
3
- def method_missing(method)
4
- return instance_variable_get("@#{method}") if instance_variable_defined?("@#{method}")
5
- instance_variable_set("@#{method}", @line[@definition.send(method)].strip)
3
+ def method_missing(method_name)
4
+ return instance_variable_get("@#{method_name}") if instance_variable_defined?("@#{method_name}")
5
+ instance_variable_set("@#{method_name}", @line[@definition.send(method_name)].strip)
6
6
  end
7
7
 
8
8
  def respond_to_missing?(method_name, include_private = false)
9
- return true unless definition.respond_to?(method_name)
9
+ return true if definition.respond_to?(method_name)
10
10
  super
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Cnab
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -2,5 +2,5 @@
2
2
  012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
3
3
  0123456789012T4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
4
4
  0123456789012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
5
- 0123456589012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
6
- 0123456589012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
5
+ 012345658901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
6
+ 012345658901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
@@ -20,7 +20,7 @@ describe Cnab::Detalhe::SegmentoTU do
20
20
  end
21
21
 
22
22
  it "should raise an error if no segmento has the attribute" do
23
- lambda { @segmento_t_u.valor_total }.should raise_error(NoMethodError)
23
+ lambda { @segmento_t_u.valor_total }.should raise_error(NameError)
24
24
  end
25
25
  end
26
26
  end
@@ -2,47 +2,81 @@ require 'spec_helper'
2
2
 
3
3
  describe Cnab do
4
4
  describe "#parse" do
5
- context "withouth file" do
5
+ context "withouth a file" do
6
6
  it "should raise an exception" do
7
7
  lambda { Cnab.parse }.should raise_error Cnab::Exceptions::NoFileGiven
8
8
  end
9
9
  end
10
10
 
11
- context "with a file" do
12
- context "and merge equal false" do
13
- it "should return a Retorno instance" do
14
- Cnab.parse("spec/cnab.txt").should be_an_instance_of(Cnab::Retorno)
15
- end
11
+ it "should return a Retorno instance" do
12
+ Cnab.parse("spec/cnab.txt").should be_an_instance_of(Cnab::Retorno)
13
+ end
16
14
 
17
- it "should return a HeaderArquivo instance" do
18
- Cnab.parse("spec/cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
19
- end
15
+ it "should return a HeaderArquivo instance" do
16
+ Cnab.parse("spec/cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
17
+ end
20
18
 
21
- it "should return a HeaderLote instance" do
22
- Cnab.parse("spec/cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
23
- end
19
+ it "should return a HeaderLote instance" do
20
+ Cnab.parse("spec/cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
21
+ end
24
22
 
25
- it "should return an array of detalhes" do
26
- Cnab.parse("spec/cnab.txt").detalhes.should be_an_instance_of(Array)
27
- end
23
+ it "should return an array of detalhes" do
24
+ Cnab.parse("spec/cnab.txt").detalhes.should be_an_instance_of(Array)
25
+ end
28
26
 
29
- it "should return an SegmentoT instance inside detalhes array" do
30
- Cnab.parse("spec/cnab.txt").detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoT)
31
- end
27
+ it "should return a TrailerLote instance" do
28
+ Cnab.parse("spec/cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
29
+ end
30
+
31
+ it "should return a TrailerArquivo instance" do
32
+ Cnab.parse("spec/cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
33
+ end
32
34
 
33
- it "should return a TrailerLote instance" do
34
- Cnab.parse("spec/cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
35
- end
35
+ context "with merge equal false" do
36
+ it "should return an SegmentoT instance inside detalhes array" do
37
+ Cnab.parse("spec/cnab.txt").detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoT)
38
+ end
39
+ end
40
+
41
+ context "with merge equal true" do
42
+ it "should return an SegmentoTU instance inside detalhes array" do
43
+ Cnab.parse("spec/cnab.txt", true).detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoTU)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "parsed object" do
49
+ it "should respond_to #densidade" do
50
+ Cnab.parse("spec/cnab.txt").header_arquivo.densidade.should == "67890"
51
+ end
52
+
53
+ it "should respond_to #informacao1" do
54
+ Cnab.parse("spec/cnab.txt").header_lote.informacao1.should == "3456789012345678901234567890123456789012"
55
+ end
56
+
57
+ it "should respond_to #id_titulo" do
58
+ Cnab.parse("spec/cnab.txt").detalhes[0].id_titulo.should == "78901234567890123456"
59
+ end
60
+
61
+ it "should respond_to #valor_iof" do
62
+ Cnab.parse("spec/cnab.txt").detalhes[1].valor_iof.should == "234567890123456"
63
+ end
64
+
65
+ it "should respond_to #qtd_registros" do
66
+ Cnab.parse("spec/cnab.txt").trailer_lote.qtd_registros.should == "789012"
67
+ end
68
+
69
+ it "should respond_to #qtd_lotes" do
70
+ Cnab.parse("spec/cnab.txt").trailer_arquivo.qtd_lotes.should == "789012"
71
+ end
36
72
 
37
- it "should return a TrailerArquivo instance" do
38
- Cnab.parse("spec/cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
39
- end
73
+ context "with merged #detalhes" do
74
+ it "should respond_to #id_titulo" do
75
+ Cnab.parse("spec/cnab.txt", true).detalhes[0].id_titulo.should == "78901234567890123456"
40
76
  end
41
77
 
42
- context "and merge equal true" do
43
- it "should return an SegmentoTU instance inside detalhes array" do
44
- Cnab.parse("spec/cnab.txt", true).detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoTU)
45
- end
78
+ it "should respond_to #valor_iof" do
79
+ Cnab.parse("spec/cnab.txt", true).detalhes[0].valor_iof.should == "234567890123456"
46
80
  end
47
81
  end
48
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cnab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-05 00:00:00.000000000 Z
13
+ date: 2013-04-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  segments:
151
151
  - 0
152
- hash: -1092611077032097692
152
+ hash: -4380411786181304562
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  none: false
155
155
  requirements:
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  segments:
160
160
  - 0
161
- hash: -1092611077032097692
161
+ hash: -4380411786181304562
162
162
  requirements: []
163
163
  rubyforge_project:
164
164
  rubygems_version: 1.8.25