br_danfe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +70 -0
  3. data/lib/br_danfe/dest.rb +10 -2
  4. data/lib/br_danfe/document.rb +10 -2
  5. data/lib/br_danfe/emit.rb +1 -1
  6. data/lib/br_danfe/helper.rb +30 -6
  7. data/lib/br_danfe/version.rb +1 -1
  8. data/lib/br_danfe/xml.rb +4 -0
  9. data/spec/features/br_danfe_spec.rb +111 -81
  10. data/spec/fixtures/lib/dest.pdf +279 -0
  11. data/spec/fixtures/{nfe_simples_nacional.xml → v2.00/nfe_simples_nacional.xml} +0 -0
  12. data/spec/fixtures/{nfe_simples_nacional.xml.fixture.pdf → v2.00/nfe_simples_nacional.xml.fixture.pdf} +4 -18
  13. data/spec/fixtures/{nfe_with_cpf.xml → v2.00/nfe_with_cpf.xml} +0 -0
  14. data/spec/fixtures/{nfe_with_cpf.xml.fixture.pdf → v2.00/nfe_with_cpf.xml.fixture.pdf} +4 -18
  15. data/spec/fixtures/{nfe_with_extra_volumes.xml → v2.00/nfe_with_extra_volumes.xml} +0 -0
  16. data/spec/fixtures/{nfe_with_extra_volumes.xml.fixture.pdf → v2.00/nfe_with_extra_volumes.xml.fixture.pdf} +6 -13
  17. data/spec/fixtures/{nfe_with_fci.xml → v2.00/nfe_with_fci.xml} +0 -0
  18. data/spec/fixtures/{nfe_with_fci.xml.fixture.pdf → v2.00/nfe_with_fci.xml.fixture.pdf} +4 -18
  19. data/spec/fixtures/{nfe_with_logo.xml → v2.00/nfe_with_logo.xml} +0 -0
  20. data/spec/fixtures/{nfe_with_logo.xml.fixture.pdf → v2.00/nfe_with_logo.xml.fixture.pdf} +6 -20
  21. data/spec/fixtures/{nfe_with_logo.xml.logo.png → v2.00/nfe_with_logo.xml.logo.png} +0 -0
  22. data/spec/fixtures/{nfe_with_ns.xml → v2.00/nfe_with_ns.xml} +0 -0
  23. data/spec/fixtures/{nfe_with_ns.xml.fixture.pdf → v2.00/nfe_with_ns.xml.fixture.pdf} +6 -13
  24. data/spec/fixtures/{nfe_without_ns.xml → v2.00/nfe_without_ns.xml} +0 -0
  25. data/spec/fixtures/{nfe_without_ns.xml.fixture.pdf → v2.00/nfe_without_ns.xml.fixture.pdf} +4 -18
  26. data/spec/fixtures/v3.10/nfe_simples_nacional.xml +1 -0
  27. data/spec/fixtures/v3.10/nfe_simples_nacional.xml.fixture.pdf +2619 -0
  28. data/spec/lib/dest_spec.rb +99 -0
  29. data/spec/lib/helper_spec.rb +46 -1
  30. data/spec/lib/xml_spec.rb +37 -0
  31. metadata +42 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24eba63681a40040bfa5b2ef632cd029891fe384
4
- data.tar.gz: b9ac26036d59bf03232df57c590a82bb2cb404b8
3
+ metadata.gz: bfdad1f5eba72650cb7f3502c4d255378cacf217
4
+ data.tar.gz: 1652da945d3f4eca2f6f03dd7b3ef53ebef14aa1
5
5
  SHA512:
6
- metadata.gz: 710fd0835151a2b5acb85c1a947eacdbea635211b3845fb3c463a00bf38475b826dbe60217816e6879614dc3589a42771b5c4e0a1d04a176db769669b4cc7938
7
- data.tar.gz: b7ed4f47d1b50814dabe29244c0210a133a50e23b8ff05672207868033404f1acdf0f6ccbc3ac62b0717a62d9c9bf411870e356b7ba69f938c2575dd94f6fb0d
6
+ metadata.gz: 91a9a8b20bac8d845542f37412512d57b7ea924ef1a597630336c2677eca5ca9e198a2589f4704f3b13b1fc912caa35ba76e21b3fe032a5acbecf4bd42a23c6b
7
+ data.tar.gz: f6d94fb7f01dfaa286651136c5a4c6bfda71606f6e54c91a2a3c6929bfcd210b36dddb978a7b1079047e6d50434bd16f5b11d53e52aed13927892cae2b252ef1
data/README.md CHANGED
@@ -6,6 +6,14 @@ This gem generates PDF files for Brazilian DANFE (_Documento Auxiliar da Nota Fi
6
6
 
7
7
  This gem requires `ruby >= 1.9.x`.
8
8
 
9
+ ## Supported NF-e versions
10
+
11
+ XML version | Supported?
12
+ ----------- | ----------
13
+ 1.00 | no
14
+ 2.00 | yes
15
+ 3.10 | yes
16
+
9
17
  ## Installing
10
18
 
11
19
  gem install ruby_danfe
@@ -86,6 +94,68 @@ You can do this automagically running the following taks:
86
94
 
87
95
  Code coverage is available through of SimpleCov. Just run `rspec` and open the coverage report in your browser.
88
96
 
97
+ #### Generating new fixtures
98
+
99
+ If you need to generate new danfes for using as fixtures, please don't use real data.
100
+
101
+ These data bellow are suggested:
102
+
103
+ **Sender:**
104
+
105
+ Field | Content
106
+ ------------ | ----------------------
107
+ Name | Nome do Remetente Ltda
108
+ Trade | Nome Fantasia do Remetente Ltda
109
+ Address | Rua do Remetente
110
+ Number | 123
111
+ Complement | Casa
112
+ Neighborhood | Bairro do Remetente
113
+ CEP | 12.345-678
114
+ City | São Paulo - SP
115
+ Phone | (11) 1234-5678
116
+ CNPJ | 62.013.294/0001-43
117
+ IE | 526.926.313.553
118
+
119
+ **Recipient:**
120
+
121
+ Field | Content
122
+ ------------ | -------------------------
123
+ Name | Nome do Destinatário PJ Ltda
124
+ Address | Rua do Destinatário PJ
125
+ Number | 345
126
+ Complement | SL 1 e 2
127
+ Neighborhood | Bairro do Destinatário PJ
128
+ CEP | 23.456-789
129
+ City | Sumaré - SP
130
+ Phone | (19) 2345-6789
131
+ CNPJ | 71.058.884/0001-83
132
+ IE | 671.008.375.110
133
+
134
+ Field | Content
135
+ ------------ | -------------------------
136
+ Name | Nome do Destinatário PF
137
+ Address | Rua do Destinatário PF
138
+ Number | 345
139
+ Complement | 1o Andar
140
+ Neighborhood | Bairro do Destinatário PF
141
+ CEP | 98.765-432
142
+ City | Vinhedo - SP
143
+ Phone | (16) 4567-8901
144
+ CPF | 485.325.574-57
145
+ RG | 11.420.947-9
146
+
147
+ **Transporter:**
148
+
149
+ Field | Content
150
+ ------------ | --------------------------
151
+ Name | Nome do Transportador Ltda
152
+ Address | Rua do Transportador, 456
153
+ City | Votorantim - SP
154
+ CNPJ | 71.434.064/0001-49
155
+ IE | 964.508.990.089
156
+
157
+ You can generate new data using [4devs generators](http://www.4devs.com.br).
158
+
89
159
  ### Building and publishing
90
160
 
91
161
  You can build using one of the above tasks
data/lib/br_danfe/dest.rb CHANGED
@@ -42,7 +42,11 @@ module BrDanfe
42
42
  @pdf.ibox 0.85, 10.16, 0.25, 9.43, I18n.t("danfe.enderDest.xLgr"), street
43
43
  @pdf.lbox 0.85, 4.83, 10.41, 9.43, @xml, "enderDest/xBairro"
44
44
  @pdf.ibox 0.85, 2.67, 15.24, 9.43, I18n.t("danfe.enderDest.CEP"), cep
45
- @pdf.idate 0.85, 2.92, 17.90, 9.43, "ide.dSaiEnt", @xml["ide/dSaiEnt"], { align: :right }
45
+ if @xml.version_310?
46
+ @pdf.idate 0.85, 2.92, 17.90, 9.43, "ide.dSaiEnt", @xml["ide/dhSaiEnt"], { align: :right }
47
+ else
48
+ @pdf.idate 0.85, 2.92, 17.90, 9.43, "ide.dSaiEnt", @xml["ide/dSaiEnt"], { align: :right }
49
+ end
46
50
  end
47
51
 
48
52
  def street
@@ -58,7 +62,11 @@ module BrDanfe
58
62
  @pdf.ibox 0.85, 4.06, 7.36, 10.28, I18n.t("danfe.enderDest.fone"), phone
59
63
  @pdf.lbox 0.85, 1.14, 11.42, 10.28, @xml, "enderDest/UF"
60
64
  @pdf.ibox 0.85, 5.33, 12.56, 10.28, I18n.t("danfe.dest.IE"), ie
61
- @pdf.idate 0.85, 2.92, 17.90, 10.28, "ide.hSaiEnt", @xml["ide/dSaiEnt"], { align: :right }
65
+ if @xml.version_310?
66
+ @pdf.itime 0.85, 2.92, 17.90, 10.28, "ide.hSaiEnt", @xml["ide/dhSaiEnt"], { align: :right }
67
+ else
68
+ @pdf.itime 0.85, 2.92, 17.90, 10.28, "ide.hSaiEnt", @xml["ide/hSaiEnt"], { align: :right }
69
+ end
62
70
  end
63
71
 
64
72
  def phone
@@ -41,8 +41,16 @@ module BrDanfe
41
41
  end
42
42
 
43
43
  def idate(h, w, x, y, i18n = "", info = "", options = {})
44
- tt = info.split("-")
45
- data = "#{tt[2]}/#{tt[1]}/#{tt[0]}"
44
+ data = BrDanfe::Helper::format_date(info)
45
+
46
+ label = ""
47
+ label = I18n.t("danfe.#{i18n}") if i18n != ""
48
+
49
+ ibox h, w, x, y, label, data, options
50
+ end
51
+
52
+ def itime(h, w, x, y, i18n = "", info = "", options = {})
53
+ data = BrDanfe::Helper::format_time(info)
46
54
 
47
55
  label = ""
48
56
  label = I18n.t("danfe.#{i18n}") if i18n != ""
data/lib/br_danfe/emit.rb CHANGED
@@ -87,7 +87,7 @@ module BrDanfe
87
87
  end
88
88
 
89
89
  def protocol_box
90
- @pdf.ibox 0.85, 10.02, 10.79, 6.46, I18n.t("danfe.infProt"), @xml["infProt/nProt"] + " " + Helper.format_date(@xml["infProt/dhRecbto"]), { align: :center }
90
+ @pdf.ibox 0.85, 10.02, 10.79, 6.46, I18n.t("danfe.infProt"), @xml["infProt/nProt"] + " " + Helper.format_datetime(@xml["infProt/dhRecbto"]), { align: :center }
91
91
  end
92
92
 
93
93
  def ie_box
@@ -11,15 +11,39 @@ module BrDanfe
11
11
  28.7.cm - y
12
12
  end
13
13
 
14
- def self.format_date(string)
15
- formated_date = ""
14
+ def self.format_datetime(xml_datetime)
15
+ formated = ""
16
16
 
17
- if not string.empty?
18
- date = DateTime.strptime(string, "%Y-%m-%dT%H:%M:%S")
19
- formated_date = date.strftime("%d/%m/%Y %H:%M:%S")
17
+ if !xml_datetime.empty?
18
+ date = DateTime.strptime(xml_datetime, "%Y-%m-%dT%H:%M:%S")
19
+ formated = date.strftime("%d/%m/%Y %H:%M:%S")
20
20
  end
21
21
 
22
- formated_date
22
+ formated
23
+ end
24
+
25
+ def self.format_date(xml_datetime)
26
+ formated = ""
27
+
28
+ if !xml_datetime.empty?
29
+ date = DateTime.strptime(xml_datetime, "%Y-%m-%d")
30
+ formated = date.strftime("%d/%m/%Y")
31
+ end
32
+
33
+ formated
34
+ end
35
+
36
+ def self.format_time(xml_datetime)
37
+ formated = ""
38
+
39
+ if xml_datetime.length == 8
40
+ formated = xml_datetime
41
+ elsif xml_datetime.length > 8
42
+ date = DateTime.strptime(xml_datetime, "%Y-%m-%dT%H:%M:%S %Z").to_time
43
+ formated = date.getutc.strftime("%H:%M:%S")
44
+ end
45
+
46
+ formated
23
47
  end
24
48
 
25
49
  def self.has_no_fiscal_value?(xml)
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/br_danfe/xml.rb CHANGED
@@ -28,5 +28,9 @@ module BrDanfe
28
28
  end
29
29
  result
30
30
  end
31
+
32
+ def version_310?
33
+ @xml.css("infNFe").attr("versao").to_s == "3.10"
34
+ end
31
35
  end
32
36
  end
@@ -1,133 +1,163 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "BrDanfe generated pdf files" do
4
- let(:base_dir) { "./spec/fixtures/"}
3
+ describe BrDanfe::Danfe do
5
4
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
5
 
7
- describe "#render_pdf" do
8
- it "renders a basic NF-e with namespace" do
9
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
6
+ context "when xml's version is v2.00" do
7
+ let(:base_dir) { "./spec/fixtures/v2.00/"}
10
8
 
11
- expected = IO.binread("#{base_dir}nfe_with_ns.xml.fixture.pdf")
9
+ describe "#render_pdf" do
10
+ it "renders a basic NF-e with namespace" do
11
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
12
12
 
13
- expect(danfe.render_pdf).to eq expected
14
- end
13
+ expected = IO.binread("#{base_dir}nfe_with_ns.xml.fixture.pdf")
15
14
 
16
- it "renders another basic NF-e without namespace" do
17
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
15
+ expect(danfe.render_pdf).to eq expected
16
+ end
18
17
 
19
- expected = IO.binread("#{base_dir}nfe_without_ns.xml.fixture.pdf")
18
+ it "renders another basic NF-e without namespace" do
19
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
20
20
 
21
- expect(danfe.render_pdf).to eq expected
22
- end
21
+ expected = IO.binread("#{base_dir}nfe_without_ns.xml.fixture.pdf")
23
22
 
24
- it "renders a NF-e having FCI in its items" do
25
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
23
+ expect(danfe.render_pdf).to eq expected
24
+ end
26
25
 
27
- expected = IO.binread("#{base_dir}nfe_with_fci.xml.fixture.pdf")
26
+ it "renders a NF-e having FCI in its items" do
27
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
28
28
 
29
- expect(danfe.render_pdf).to eq expected
30
- end
29
+ expected = IO.binread("#{base_dir}nfe_with_fci.xml.fixture.pdf")
31
30
 
32
- it "renders a Simples Nacional NF-e using CSOSN" do
33
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
31
+ expect(danfe.render_pdf).to eq expected
32
+ end
34
33
 
35
- expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
34
+ it "renders a Simples Nacional NF-e using CSOSN" do
35
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
36
36
 
37
- expect(danfe.render_pdf).to eq expected
38
- end
37
+ expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
39
38
 
40
- it "renders a NF-e with extra volumes" do
41
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
39
+ expect(danfe.render_pdf).to eq expected
40
+ end
42
41
 
43
- expected = IO.binread("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf")
42
+ it "renders a NF-e with extra volumes" do
43
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
44
44
 
45
- expect(danfe.render_pdf).to eq expected
46
- end
45
+ expected = IO.binread("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf")
47
46
 
48
- it "renders a NF-e with logo" do
49
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
50
- danfe.options.logo_path = "./spec/fixtures/nfe_with_logo.xml.logo.png"
47
+ expect(danfe.render_pdf).to eq expected
48
+ end
51
49
 
52
- expected = IO.binread("#{base_dir}nfe_with_logo.xml.fixture.pdf")
50
+ it "renders a NF-e with logo" do
51
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
52
+ danfe.options.logo_path = "#{base_dir}nfe_with_logo.xml.logo.png"
53
53
 
54
- expect(danfe.render_pdf).to eq expected
55
- end
54
+ expected = IO.binread("#{base_dir}nfe_with_logo.xml.fixture.pdf")
56
55
 
57
- it "renders a NF-e with CPF" do
58
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
56
+ expect(danfe.render_pdf).to eq expected
57
+ end
59
58
 
60
- expected = IO.binread("#{base_dir}nfe_with_cpf.xml.fixture.pdf")
59
+ it "renders a NF-e with CPF" do
60
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
61
61
 
62
- expect(danfe.render_pdf).to eq expected
62
+ expected = IO.binread("#{base_dir}nfe_with_cpf.xml.fixture.pdf")
63
+
64
+ expect(danfe.render_pdf).to eq expected
65
+ end
63
66
  end
64
- end
65
67
 
66
- describe "#save_pdf" do
67
- before { File.delete(output_pdf) if File.exist?(output_pdf) }
68
+ describe "#save_pdf" do
69
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
68
70
 
69
- it "renders a basic NF-e with namespace" do
70
- expect(File.exist?(output_pdf)).to be_falsey
71
+ it "renders a basic NF-e with namespace" do
72
+ expect(File.exist?(output_pdf)).to be_falsey
71
73
 
72
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
73
- danfe.save_pdf output_pdf
74
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
75
+ danfe.save_pdf output_pdf
74
76
 
75
- expect("#{base_dir}nfe_with_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
76
- end
77
+ expect("#{base_dir}nfe_with_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
78
+ end
77
79
 
78
- it "renders another basic NF-e without namespace" do
79
- expect(File.exist?(output_pdf)).to be_falsey
80
+ it "renders another basic NF-e without namespace" do
81
+ expect(File.exist?(output_pdf)).to be_falsey
80
82
 
81
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
82
- danfe.save_pdf output_pdf
83
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
84
+ danfe.save_pdf output_pdf
83
85
 
84
- expect("#{base_dir}nfe_without_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
85
- end
86
+ expect("#{base_dir}nfe_without_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
87
+ end
86
88
 
87
- it "renders a NF-e having FCI in its items" do
88
- expect(File.exist?(output_pdf)).to be_falsey
89
+ it "renders a NF-e having FCI in its items" do
90
+ expect(File.exist?(output_pdf)).to be_falsey
89
91
 
90
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
91
- danfe.save_pdf output_pdf
92
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
93
+ danfe.save_pdf output_pdf
92
94
 
93
- expect("#{base_dir}nfe_with_fci.xml.fixture.pdf").to be_same_file_as(output_pdf)
94
- end
95
+ expect("#{base_dir}nfe_with_fci.xml.fixture.pdf").to be_same_file_as(output_pdf)
96
+ end
95
97
 
96
- it "renders a Simples Nacional NF-e using CSOSN" do
97
- expect(File.exist?(output_pdf)).to be_falsey
98
+ it "renders a Simples Nacional NF-e using CSOSN" do
99
+ expect(File.exist?(output_pdf)).to be_falsey
98
100
 
99
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
100
- danfe.save_pdf output_pdf
101
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
102
+ danfe.save_pdf output_pdf
101
103
 
102
- expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to be_same_file_as(output_pdf)
103
- end
104
+ expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to be_same_file_as(output_pdf)
105
+ end
106
+
107
+ it "renders a NF-e with extra volumes" do
108
+ expect(File.exist?(output_pdf)).to be_falsey
109
+
110
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
111
+ danfe.save_pdf output_pdf
112
+
113
+ expect("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf").to be_same_file_as(output_pdf)
114
+ end
115
+
116
+ it "renders a NF-e with logo" do
117
+ expect(File.exist?(output_pdf)).to be_falsey
104
118
 
105
- it "renders a NF-e with extra volumes" do
106
- expect(File.exist?(output_pdf)).to be_falsey
119
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
120
+ danfe.options.logo_path = "#{base_dir}nfe_with_logo.xml.logo.png"
121
+ danfe.save_pdf output_pdf
107
122
 
108
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
109
- danfe.save_pdf output_pdf
123
+ expect("#{base_dir}nfe_with_logo.xml.fixture.pdf").to be_same_file_as(output_pdf)
124
+ end
110
125
 
111
- expect("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf").to be_same_file_as(output_pdf)
126
+ it "renders a NF-e with CPF" do
127
+ expect(File.exist?(output_pdf)).to be_falsey
128
+
129
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
130
+ danfe.save_pdf output_pdf
131
+
132
+ expect("#{base_dir}nfe_with_cpf.xml.fixture.pdf").to be_same_file_as(output_pdf)
133
+ end
112
134
  end
135
+ end
113
136
 
114
- it "renders a NF-e with logo" do
115
- expect(File.exist?(output_pdf)).to be_falsey
137
+ context "when xml's version is v3.10" do
138
+ let(:base_dir) { "./spec/fixtures/v3.10/"}
116
139
 
117
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
118
- danfe.options.logo_path = "./spec/fixtures/nfe_with_logo.xml.logo.png"
119
- danfe.save_pdf output_pdf
140
+ describe "#render_pdf" do
141
+ it "renders a Simples Nacional NF-e using CSOSN" do
142
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
120
143
 
121
- expect("#{base_dir}nfe_with_logo.xml.fixture.pdf").to be_same_file_as(output_pdf)
144
+ expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
145
+
146
+ expect(danfe.render_pdf).to eq expected
147
+ end
122
148
  end
123
149
 
124
- it "renders a NF-e with CPF" do
125
- expect(File.exist?(output_pdf)).to be_falsey
150
+ describe "#save_pdf" do
151
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
152
+
153
+ it "renders a Simples Nacional NF-e using CSOSN" do
154
+ expect(File.exist?(output_pdf)).to be_falsey
126
155
 
127
- danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
128
- danfe.save_pdf output_pdf
156
+ danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
157
+ danfe.save_pdf output_pdf
129
158
 
130
- expect("#{base_dir}nfe_with_cpf.xml.fixture.pdf").to be_same_file_as(output_pdf)
159
+ expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to be_same_file_as(output_pdf)
160
+ end
131
161
  end
132
162
  end
133
163
  end