br_danfe 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +3 -26
- data/Rakefile +0 -40
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe/vol.rb +6 -0
- data/spec/features/danfe_spec.rb +85 -0
- data/spec/fixtures/lib/vol#render-blank-boxes.pdf +117 -0
- data/spec/fixtures/v2.00/nfe_simples_nacional.xml.fixture.pdf +58 -4
- data/spec/fixtures/v3.10/nfe_simples_nacional.xml.fixture.pdf +58 -4
- data/spec/lib/dest_spec.rb +5 -5
- data/spec/lib/det_body_spec.rb +4 -4
- data/spec/lib/det_header_spec.rb +1 -1
- data/spec/lib/document_spec.rb +6 -6
- data/spec/lib/dup_spec.rb +1 -1
- data/spec/lib/emit_header_spec.rb +2 -2
- data/spec/lib/emit_spec.rb +1 -1
- data/spec/lib/icmstot_spec.rb +1 -1
- data/spec/lib/infadic_spec.rb +2 -2
- data/spec/lib/issqn_spec.rb +1 -1
- data/spec/lib/options_spec.rb +2 -2
- data/spec/lib/ticket_spec.rb +1 -1
- data/spec/lib/transp_spec.rb +5 -5
- data/spec/lib/vol_spec.rb +22 -1
- data/spec/spec_helper.rb +5 -1
- data/spec/support/have_same_content_of.rb +29 -0
- metadata +8 -8
- data/spec/features/br_danfe_spec.rb +0 -127
- data/spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf +0 -1940
- data/spec/support/be_same_file_as.rb +0 -9
data/spec/lib/icmstot_spec.rb
CHANGED
data/spec/lib/infadic_spec.rb
CHANGED
|
@@ -59,7 +59,7 @@ describe BrDanfe::Infadic do
|
|
|
59
59
|
|
|
60
60
|
pdf.render_file output_pdf
|
|
61
61
|
|
|
62
|
-
expect("#{base_dir}infadic#render.pdf").to
|
|
62
|
+
expect("#{base_dir}infadic#render.pdf").to have_same_content_of file: output_pdf
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -74,7 +74,7 @@ describe BrDanfe::Infadic do
|
|
|
74
74
|
|
|
75
75
|
pdf.render_file output_pdf
|
|
76
76
|
|
|
77
|
-
expect("#{base_dir}infadic#render-extra_volume.pdf").to
|
|
77
|
+
expect("#{base_dir}infadic#render-extra_volume.pdf").to have_same_content_of file: output_pdf
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
end
|
data/spec/lib/issqn_spec.rb
CHANGED
data/spec/lib/options_spec.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe BrDanfe::Options do
|
|
4
|
-
it "
|
|
4
|
+
it "returns the default config set in the code" do
|
|
5
5
|
options = BrDanfe::Options.new
|
|
6
6
|
expect(options.logo_path).to eq("")
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
it "
|
|
9
|
+
it "returns the config set in params" do
|
|
10
10
|
options = BrDanfe::Options.new({"logo_path" => "/fake/path/file.png"})
|
|
11
11
|
expect(options.logo_path).to eq("/fake/path/file.png")
|
|
12
12
|
end
|
data/spec/lib/ticket_spec.rb
CHANGED
data/spec/lib/transp_spec.rb
CHANGED
|
@@ -45,7 +45,7 @@ describe BrDanfe::Transp do
|
|
|
45
45
|
|
|
46
46
|
pdf.render_file output_pdf
|
|
47
47
|
|
|
48
|
-
expect("#{base_dir}transp#render.pdf").to
|
|
48
|
+
expect("#{base_dir}transp#render.pdf").to have_same_content_of file: output_pdf
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
context "when modFrete is 0" do
|
|
@@ -66,7 +66,7 @@ describe BrDanfe::Transp do
|
|
|
66
66
|
|
|
67
67
|
pdf.render_file output_pdf
|
|
68
68
|
|
|
69
|
-
expect("#{base_dir}transp#render-modfrete_0.pdf").to
|
|
69
|
+
expect("#{base_dir}transp#render-modfrete_0.pdf").to have_same_content_of file: output_pdf
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -88,7 +88,7 @@ describe BrDanfe::Transp do
|
|
|
88
88
|
|
|
89
89
|
pdf.render_file output_pdf
|
|
90
90
|
|
|
91
|
-
expect("#{base_dir}transp#render-modfrete_1.pdf").to
|
|
91
|
+
expect("#{base_dir}transp#render-modfrete_1.pdf").to have_same_content_of file: output_pdf
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
@@ -110,7 +110,7 @@ describe BrDanfe::Transp do
|
|
|
110
110
|
|
|
111
111
|
pdf.render_file output_pdf
|
|
112
112
|
|
|
113
|
-
expect("#{base_dir}transp#render-modfrete_2.pdf").to
|
|
113
|
+
expect("#{base_dir}transp#render-modfrete_2.pdf").to have_same_content_of file: output_pdf
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
|
|
@@ -132,7 +132,7 @@ describe BrDanfe::Transp do
|
|
|
132
132
|
|
|
133
133
|
pdf.render_file output_pdf
|
|
134
134
|
|
|
135
|
-
expect("#{base_dir}transp#render-modfrete_9.pdf").to
|
|
135
|
+
expect("#{base_dir}transp#render-modfrete_9.pdf").to have_same_content_of file: output_pdf
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
end
|
data/spec/lib/vol_spec.rb
CHANGED
|
@@ -55,11 +55,32 @@ describe BrDanfe::Vol do
|
|
|
55
55
|
|
|
56
56
|
pdf.render_file output_pdf
|
|
57
57
|
|
|
58
|
-
expect("#{base_dir}vol#render.pdf").to
|
|
58
|
+
expect("#{base_dir}vol#render.pdf").to have_same_content_of file: output_pdf
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "returns the quantity of volumes" do
|
|
62
62
|
expect(subject.render).to eq 3
|
|
63
63
|
end
|
|
64
|
+
|
|
65
|
+
context "when any <vol> tag is found" do
|
|
66
|
+
let(:xml_as_string) do
|
|
67
|
+
<<-eos
|
|
68
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
|
69
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
|
70
|
+
<transp>
|
|
71
|
+
</transp>
|
|
72
|
+
</infNFe>
|
|
73
|
+
</NFe>
|
|
74
|
+
eos
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "renders blank boxes" do
|
|
78
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
|
79
|
+
|
|
80
|
+
pdf.render_file output_pdf
|
|
81
|
+
|
|
82
|
+
expect("#{base_dir}vol#render-blank-boxes.pdf").to have_same_content_of file: output_pdf
|
|
83
|
+
end
|
|
84
|
+
end
|
|
64
85
|
end
|
|
65
86
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
RSpec::Matchers.define(:have_same_content_of) do |file: nil|
|
|
2
|
+
expected_file_path = file
|
|
3
|
+
|
|
4
|
+
match do |actual_file_path|
|
|
5
|
+
if File.exists?(actual_file_path)
|
|
6
|
+
expect(md5_hash(actual_file_path)).to eq(md5_hash(expected_file_path))
|
|
7
|
+
else
|
|
8
|
+
create_when_missing(expected_file_path, actual_file_path)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def md5_hash(file_path)
|
|
13
|
+
Digest::MD5.hexdigest(File.read(file_path))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_when_missing(expected_file_path, actual_file_path)
|
|
17
|
+
puts "+----------------------------------------------------"
|
|
18
|
+
puts "|"
|
|
19
|
+
puts "| The file bellow doesn't exists and will be created:"
|
|
20
|
+
puts "|"
|
|
21
|
+
puts "| #{actual_file_path}"
|
|
22
|
+
puts "|"
|
|
23
|
+
puts "+----------------------------------------------------"
|
|
24
|
+
|
|
25
|
+
FileUtils.cp(expected_file_path, actual_file_path)
|
|
26
|
+
|
|
27
|
+
false
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: br_danfe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ASSEINFO
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-01-
|
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -176,7 +176,7 @@ files:
|
|
|
176
176
|
- lib/br_danfe/vol.rb
|
|
177
177
|
- lib/br_danfe/xml.rb
|
|
178
178
|
- lib/br_danfe/xprod.rb
|
|
179
|
-
- spec/features/
|
|
179
|
+
- spec/features/danfe_spec.rb
|
|
180
180
|
- spec/fixtures/lib/dest#render-v2.00.pdf
|
|
181
181
|
- spec/fixtures/lib/dest#render-v3.10.pdf
|
|
182
182
|
- spec/fixtures/lib/dest#render-with_cnpj.pdf
|
|
@@ -207,6 +207,7 @@ files:
|
|
|
207
207
|
- spec/fixtures/lib/transp#render-modfrete_2.pdf
|
|
208
208
|
- spec/fixtures/lib/transp#render-modfrete_9.pdf
|
|
209
209
|
- spec/fixtures/lib/transp#render.pdf
|
|
210
|
+
- spec/fixtures/lib/vol#render-blank-boxes.pdf
|
|
210
211
|
- spec/fixtures/lib/vol#render.pdf
|
|
211
212
|
- spec/fixtures/logo.png
|
|
212
213
|
- spec/fixtures/v2.00/nfe_simples_nacional.xml
|
|
@@ -216,7 +217,6 @@ files:
|
|
|
216
217
|
- spec/fixtures/v2.00/nfe_with_fci.xml
|
|
217
218
|
- spec/fixtures/v2.00/nfe_with_fci.xml.fixture.pdf
|
|
218
219
|
- spec/fixtures/v2.00/nfe_with_logo.xml
|
|
219
|
-
- spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf
|
|
220
220
|
- spec/fixtures/v2.00/nfe_with_ns.xml
|
|
221
221
|
- spec/fixtures/v2.00/nfe_with_ns.xml.fixture.pdf
|
|
222
222
|
- spec/fixtures/v2.00/nfe_without_ns.xml
|
|
@@ -245,7 +245,7 @@ files:
|
|
|
245
245
|
- spec/lib/xml_spec.rb
|
|
246
246
|
- spec/lib/xprod_spec.rb
|
|
247
247
|
- spec/spec_helper.rb
|
|
248
|
-
- spec/support/
|
|
248
|
+
- spec/support/have_same_content_of.rb
|
|
249
249
|
homepage: http://github.com/asseinfo/br_danfe
|
|
250
250
|
licenses:
|
|
251
251
|
- MIT
|
|
@@ -271,7 +271,7 @@ signing_key:
|
|
|
271
271
|
specification_version: 4
|
|
272
272
|
summary: DANFE pdf generator for Brazilian invoices.
|
|
273
273
|
test_files:
|
|
274
|
-
- spec/features/
|
|
274
|
+
- spec/features/danfe_spec.rb
|
|
275
275
|
- spec/fixtures/lib/dest#render-v2.00.pdf
|
|
276
276
|
- spec/fixtures/lib/dest#render-v3.10.pdf
|
|
277
277
|
- spec/fixtures/lib/dest#render-with_cnpj.pdf
|
|
@@ -302,6 +302,7 @@ test_files:
|
|
|
302
302
|
- spec/fixtures/lib/transp#render-modfrete_2.pdf
|
|
303
303
|
- spec/fixtures/lib/transp#render-modfrete_9.pdf
|
|
304
304
|
- spec/fixtures/lib/transp#render.pdf
|
|
305
|
+
- spec/fixtures/lib/vol#render-blank-boxes.pdf
|
|
305
306
|
- spec/fixtures/lib/vol#render.pdf
|
|
306
307
|
- spec/fixtures/logo.png
|
|
307
308
|
- spec/fixtures/v2.00/nfe_simples_nacional.xml
|
|
@@ -311,7 +312,6 @@ test_files:
|
|
|
311
312
|
- spec/fixtures/v2.00/nfe_with_fci.xml
|
|
312
313
|
- spec/fixtures/v2.00/nfe_with_fci.xml.fixture.pdf
|
|
313
314
|
- spec/fixtures/v2.00/nfe_with_logo.xml
|
|
314
|
-
- spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf
|
|
315
315
|
- spec/fixtures/v2.00/nfe_with_ns.xml
|
|
316
316
|
- spec/fixtures/v2.00/nfe_with_ns.xml.fixture.pdf
|
|
317
317
|
- spec/fixtures/v2.00/nfe_without_ns.xml
|
|
@@ -340,4 +340,4 @@ test_files:
|
|
|
340
340
|
- spec/lib/xml_spec.rb
|
|
341
341
|
- spec/lib/xprod_spec.rb
|
|
342
342
|
- spec/spec_helper.rb
|
|
343
|
-
- spec/support/
|
|
343
|
+
- spec/support/have_same_content_of.rb
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe BrDanfe::Danfe do
|
|
4
|
-
let(:output_pdf) { "#{base_dir}output.pdf" }
|
|
5
|
-
|
|
6
|
-
context "when xml's version is v2.00" do
|
|
7
|
-
let(:base_dir) { "./spec/fixtures/v2.00/"}
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
expected = IO.binread("#{base_dir}nfe_with_ns.xml.fixture.pdf")
|
|
14
|
-
|
|
15
|
-
expect(danfe.render_pdf).to eq expected
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "renders another basic NF-e without namespace" do
|
|
19
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
|
|
20
|
-
|
|
21
|
-
expected = IO.binread("#{base_dir}nfe_without_ns.xml.fixture.pdf")
|
|
22
|
-
|
|
23
|
-
expect(danfe.render_pdf).to eq expected
|
|
24
|
-
end
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
expected = IO.binread("#{base_dir}nfe_with_fci.xml.fixture.pdf")
|
|
30
|
-
|
|
31
|
-
expect(danfe.render_pdf).to eq expected
|
|
32
|
-
end
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
|
|
38
|
-
|
|
39
|
-
expect(danfe.render_pdf).to eq expected
|
|
40
|
-
end
|
|
41
|
-
|
|
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
|
-
|
|
45
|
-
expected = IO.binread("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf")
|
|
46
|
-
|
|
47
|
-
expect(danfe.render_pdf).to eq expected
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe "#save_pdf" do
|
|
52
|
-
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
|
53
|
-
|
|
54
|
-
it "renders a basic NF-e with namespace" do
|
|
55
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
56
|
-
|
|
57
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
|
|
58
|
-
danfe.save_pdf output_pdf
|
|
59
|
-
|
|
60
|
-
expect("#{base_dir}nfe_with_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "renders another basic NF-e without namespace" do
|
|
64
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
65
|
-
|
|
66
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
|
|
67
|
-
danfe.save_pdf output_pdf
|
|
68
|
-
|
|
69
|
-
expect("#{base_dir}nfe_without_ns.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "renders a NF-e having FCI in its items" do
|
|
73
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
74
|
-
|
|
75
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
|
|
76
|
-
danfe.save_pdf output_pdf
|
|
77
|
-
|
|
78
|
-
expect("#{base_dir}nfe_with_fci.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "renders a Simples Nacional NF-e using CSOSN" do
|
|
82
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
83
|
-
|
|
84
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
|
85
|
-
danfe.save_pdf output_pdf
|
|
86
|
-
|
|
87
|
-
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "renders a NF-e with extra volumes" do
|
|
91
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
92
|
-
|
|
93
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
|
|
94
|
-
danfe.save_pdf output_pdf
|
|
95
|
-
|
|
96
|
-
expect("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context "when xml's version is v3.10" do
|
|
102
|
-
let(:base_dir) { "./spec/fixtures/v3.10/"}
|
|
103
|
-
|
|
104
|
-
describe "#render_pdf" do
|
|
105
|
-
it "renders a Simples Nacional NF-e using CSOSN" do
|
|
106
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
|
107
|
-
|
|
108
|
-
expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
|
|
109
|
-
|
|
110
|
-
expect(danfe.render_pdf).to eq expected
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
describe "#save_pdf" do
|
|
115
|
-
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
|
116
|
-
|
|
117
|
-
it "renders a Simples Nacional NF-e using CSOSN" do
|
|
118
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
|
119
|
-
|
|
120
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
|
121
|
-
danfe.save_pdf output_pdf
|
|
122
|
-
|
|
123
|
-
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|