br_danfe 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +113 -0
- data/Gemfile.lock +40 -19
- data/Rakefile +3 -3
- data/br_danfe.gemspec +7 -7
- data/lib/br_danfe.rb +14 -14
- data/lib/br_danfe/cce.rb +1 -0
- data/lib/br_danfe/cce_lib/barcode.rb +3 -2
- data/lib/br_danfe/cce_lib/correction.rb +3 -2
- data/lib/br_danfe/cce_lib/document.rb +15 -5
- data/lib/br_danfe/cce_lib/footer.rb +1 -1
- data/lib/br_danfe/cce_lib/header.rb +1 -1
- data/lib/br_danfe/cce_lib/nfe_key.rb +4 -3
- data/lib/br_danfe/cce_lib/protocol.rb +4 -3
- data/lib/br_danfe/danfe.rb +17 -17
- data/lib/br_danfe/danfe_lib/cep.rb +1 -1
- data/lib/br_danfe/danfe_lib/cst.rb +8 -6
- data/lib/br_danfe/danfe_lib/dest.rb +21 -23
- data/lib/br_danfe/danfe_lib/det_body.rb +20 -20
- data/lib/br_danfe/danfe_lib/document.rb +49 -36
- data/lib/br_danfe/danfe_lib/dup.rb +11 -10
- data/lib/br_danfe/danfe_lib/emit_header.rb +38 -34
- data/lib/br_danfe/danfe_lib/helper.rb +23 -23
- data/lib/br_danfe/danfe_lib/icmstot.rb +12 -12
- data/lib/br_danfe/danfe_lib/infadic.rb +1 -0
- data/lib/br_danfe/danfe_lib/issqn.rb +6 -6
- data/lib/br_danfe/danfe_lib/options.rb +6 -5
- data/lib/br_danfe/danfe_lib/phone.rb +2 -2
- data/lib/br_danfe/danfe_lib/ticket.rb +6 -4
- data/lib/br_danfe/danfe_lib/transp.rb +27 -26
- data/lib/br_danfe/danfe_lib/vol.rb +9 -8
- data/lib/br_danfe/danfe_lib/xml.rb +6 -6
- data/lib/br_danfe/danfe_lib/xprod.rb +22 -23
- data/lib/br_danfe/uf.rb +1 -4
- data/lib/br_danfe/version.rb +1 -1
- data/spec/features/cce_spec.rb +6 -6
- data/spec/features/danfe_spec.rb +25 -25
- data/spec/fixtures/cce/lib/barcode#render.pdf +5 -1
- data/spec/fixtures/cce/lib/correction#render.pdf +6 -2
- data/spec/fixtures/cce/lib/document#box.pdf +5 -1
- data/spec/fixtures/cce/lib/document#box.with.block.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.align.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.pad.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.simple.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.size.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.style.pdf +6 -2
- data/spec/fixtures/cce/lib/footer#render.pdf +6 -2
- data/spec/fixtures/cce/lib/header#render.pdf +6 -2
- data/spec/fixtures/cce/lib/nfe_key#render.pdf +7 -3
- data/spec/fixtures/cce/lib/protocol#render.pdf +7 -3
- data/spec/fixtures/cce/v1.00/cce.fixture.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v2.00.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v3.10.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v4.00.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_cpf.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_ie.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf +7 -3
- data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +383 -379
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +233 -229
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +3697 -3685
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +3540 -3532
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +1665 -1657
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +1665 -1657
- data/spec/fixtures/nfe/lib/document#lcnpj-blank.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lcnpj-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lcnpj-valid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-blank.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-valid.pdf +6 -2
- data/spec/fixtures/nfe/lib/dup#render.pdf +8 -4
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +9 -5
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +9 -5
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +7 -3
- data/spec/fixtures/nfe/lib/icmstot#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +8 -4
- data/spec/fixtures/nfe/lib/infadic#render-difal.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-extra_volume.pdf +8 -4
- data/spec/fixtures/nfe/lib/infadic#render-with_complementary_information.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-with_fisco_additional_information.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-with_street_data.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic_vol#render-extra_volume.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-with_issqn.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-without_issqn.pdf +5 -1
- data/spec/fixtures/nfe/lib/ticket#render.pdf +6 -2
- data/spec/fixtures/nfe/lib/transp#render-modfrete_0.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_1.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_2.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_3.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_4.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_9.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/vol#render-blank-boxes.pdf +6 -2
- data/spec/fixtures/nfe/lib/vol#render.pdf +6 -2
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +317 -313
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +315 -311
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +1297 -1289
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +165 -161
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +1297 -1289
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +314 -310
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +765 -761
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +1222 -1214
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +1222 -1214
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +4004 -3992
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +1522 -1514
- data/spec/lib/cce_lib/barcode_spec.rb +5 -5
- data/spec/lib/cce_lib/correction_spec.rb +5 -5
- data/spec/lib/cce_lib/document_spec.rb +23 -23
- data/spec/lib/cce_lib/footer_spec.rb +4 -4
- data/spec/lib/cce_lib/header_spec.rb +4 -4
- data/spec/lib/cce_lib/nfe_key_spec.rb +5 -5
- data/spec/lib/cce_lib/protocol_spec.rb +5 -5
- data/spec/lib/danfe_lib/cep_spec.rb +5 -5
- data/spec/lib/danfe_lib/cst_spec.rb +8 -8
- data/spec/lib/danfe_lib/dest_spec.rb +23 -23
- data/spec/lib/danfe_lib/det_body_spec.rb +26 -26
- data/spec/lib/danfe_lib/document_spec.rb +25 -25
- data/spec/lib/danfe_lib/dup_spec.rb +4 -4
- data/spec/lib/danfe_lib/emit_header_spec.rb +13 -13
- data/spec/lib/danfe_lib/helper_spec.rb +74 -74
- data/spec/lib/danfe_lib/icmstot_spec.rb +4 -4
- data/spec/lib/danfe_lib/infadic_spec.rb +6 -13
- data/spec/lib/danfe_lib/infadic_vol_spec.rb +1 -4
- data/spec/lib/danfe_lib/issqn_spec.rb +11 -11
- data/spec/lib/danfe_lib/logo_options_spec.rb +18 -18
- data/spec/lib/danfe_lib/options_spec.rb +7 -7
- data/spec/lib/danfe_lib/phone_spec.rb +10 -10
- data/spec/lib/danfe_lib/plate_spec.rb +9 -9
- data/spec/lib/danfe_lib/ticket_spec.rb +4 -4
- data/spec/lib/danfe_lib/transp_spec.rb +10 -10
- data/spec/lib/danfe_lib/vol_spec.rb +7 -7
- data/spec/lib/danfe_lib/xml_spec.rb +5 -5
- data/spec/lib/danfe_lib/xprod_spec.rb +48 -50
- data/spec/lib/uf_spec.rb +12 -12
- data/spec/support/have_same_content_of.rb +6 -6
- metadata +40 -10
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Icmstot do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
@@ -9,7 +9,7 @@ describe BrDanfe::DanfeLib::Icmstot do
|
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
let(:xml_as_string) do
|
14
14
|
<<-eos
|
15
15
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -37,7 +37,7 @@ describe BrDanfe::DanfeLib::Icmstot do
|
|
37
37
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'renders xml to the pdf' do
|
41
41
|
expect(File.exist?(output_pdf)).to be_falsey
|
42
42
|
|
43
43
|
pdf.render_file output_pdf
|
@@ -64,9 +64,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
64
64
|
|
65
65
|
pdf.render_file output_pdf
|
66
66
|
|
67
|
-
expect(
|
68
|
-
"#{base_dir}infadic#render.pdf"
|
69
|
-
).to have_same_content_of file: output_pdf
|
67
|
+
expect("#{base_dir}infadic#render.pdf").to have_same_content_of file: output_pdf
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
@@ -160,9 +158,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
160
158
|
|
161
159
|
pdf.render_file output_pdf
|
162
160
|
|
163
|
-
expect(
|
164
|
-
"#{base_dir}infadic#render-with_street_data.pdf"
|
165
|
-
).to have_same_content_of file: output_pdf
|
161
|
+
expect("#{base_dir}infadic#render-with_street_data.pdf").to have_same_content_of file: output_pdf
|
166
162
|
end
|
167
163
|
end
|
168
164
|
|
@@ -241,9 +237,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
241
237
|
|
242
238
|
pdf.render_file output_pdf
|
243
239
|
|
244
|
-
expect(
|
245
|
-
"#{base_dir}infadic#render-with_complementary_information.pdf"
|
246
|
-
).to have_same_content_of file: output_pdf
|
240
|
+
expect("#{base_dir}infadic#render-with_complementary_information.pdf").to have_same_content_of file: output_pdf
|
247
241
|
end
|
248
242
|
end
|
249
243
|
|
@@ -264,6 +258,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
264
258
|
expect(File.exist?(output_pdf)).to be_falsey
|
265
259
|
|
266
260
|
pdf.render_file output_pdf
|
261
|
+
|
267
262
|
expect("#{base_dir}infadic#render-with_fisco_additional_information.pdf").to have_same_content_of file: output_pdf
|
268
263
|
end
|
269
264
|
end
|
@@ -341,9 +336,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
341
336
|
|
342
337
|
pdf.render_file output_pdf
|
343
338
|
|
344
|
-
expect(
|
345
|
-
"#{base_dir}infadic#render-extra_volume.pdf"
|
346
|
-
).to have_same_content_of file: output_pdf
|
339
|
+
expect("#{base_dir}infadic#render-extra_volume.pdf").to have_same_content_of file: output_pdf
|
347
340
|
end
|
348
341
|
end
|
349
342
|
|
@@ -422,4 +415,4 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
422
415
|
end
|
423
416
|
end
|
424
417
|
end
|
425
|
-
end
|
418
|
+
end
|
@@ -87,10 +87,7 @@ describe BrDanfe::DanfeLib::InfadicVol do
|
|
87
87
|
|
88
88
|
pdf.render_file output_pdf
|
89
89
|
|
90
|
-
expect(
|
91
|
-
"#{base_dir}infadic_vol#render-extra_volume.pdf"
|
92
|
-
).to have_same_content_of file: output_pdf
|
90
|
+
expect("#{base_dir}infadic_vol#render-extra_volume.pdf").to have_same_content_of file: output_pdf
|
93
91
|
end
|
94
92
|
end
|
95
|
-
|
96
93
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Issqn do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
@@ -9,7 +9,7 @@ describe BrDanfe::DanfeLib::Issqn do
|
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
let(:xml_as_string) do
|
14
14
|
<<-eos
|
15
15
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -40,8 +40,8 @@ describe BrDanfe::DanfeLib::Issqn do
|
|
40
40
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
41
41
|
end
|
42
42
|
|
43
|
-
context
|
44
|
-
it
|
43
|
+
context 'with ISSQN' do
|
44
|
+
it 'renders xml to the pdf' do
|
45
45
|
expect(File.exist?(output_pdf)).to be_falsey
|
46
46
|
|
47
47
|
pdf.render_file output_pdf
|
@@ -49,10 +49,10 @@ describe BrDanfe::DanfeLib::Issqn do
|
|
49
49
|
expect("#{base_dir}issqn#render-with_issqn.pdf").to have_same_content_of file: output_pdf
|
50
50
|
end
|
51
51
|
|
52
|
-
context
|
53
|
-
let(:issqn) {
|
52
|
+
context 'when there is only one issqn value' do
|
53
|
+
let(:issqn) { '<vServ>1.43</vServ>' }
|
54
54
|
|
55
|
-
it
|
55
|
+
it 'renders xml to the pdf' do
|
56
56
|
expect(File.exist?(output_pdf)).to be_falsey
|
57
57
|
|
58
58
|
pdf.render_file output_pdf
|
@@ -62,10 +62,10 @@ describe BrDanfe::DanfeLib::Issqn do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
context
|
66
|
-
let(:issqn) {
|
65
|
+
context 'without ISSQN' do
|
66
|
+
let(:issqn) { '' }
|
67
67
|
|
68
|
-
it
|
68
|
+
it 'renders xml to the pdf' do
|
69
69
|
expect(File.exist?(output_pdf)).to be_falsey
|
70
70
|
|
71
71
|
pdf.render_file output_pdf
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe BrDanfe::DanfeLib::LogoOptions do
|
4
4
|
let(:box_size) { 100 }
|
@@ -8,72 +8,72 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
|
|
8
8
|
|
9
9
|
subject { described_class.new(box_size, logo_dimensions) }
|
10
10
|
|
11
|
-
describe
|
12
|
-
context
|
13
|
-
context
|
14
|
-
it
|
11
|
+
describe '#options' do
|
12
|
+
context 'when the logo dimensions are smaller than the dimensions of the box' do
|
13
|
+
context 'when the logo is square' do
|
14
|
+
it 'returns the options with logo height' do
|
15
15
|
expect(subject.options).to eq(height: 50, position: :center, vposition: :center)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
context
|
19
|
+
context 'when logo width is larger than logo height' do
|
20
20
|
let(:logo_dimensions) do
|
21
21
|
{ width: 75, height: 50 }
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'returns the options with logo width' do
|
25
25
|
expect(subject.options).to eq(width: 75, position: :center, vposition: :center)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context
|
29
|
+
context 'when logo height is larger than logo width' do
|
30
30
|
let(:logo_dimensions) do
|
31
31
|
{ width: 50, height: 75 }
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'returns the options with logo height' do
|
35
35
|
expect(subject.options).to eq(height: 75, position: :center, vposition: :center)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context
|
40
|
+
context 'when the logo dimensions are equal to the dimensions of the box' do
|
41
41
|
let(:logo_dimensions) do
|
42
42
|
{ width: 100, height: 100 }
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'returns the options with box size' do
|
46
46
|
expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
context
|
51
|
-
context
|
50
|
+
context 'when the logo dimensions are larger than the dimensions of the box' do
|
51
|
+
context 'when the logo is square' do
|
52
52
|
let(:logo_dimensions) do
|
53
53
|
{ width: 150, height: 150 }
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'returns the options with box size' do
|
57
57
|
expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
61
|
+
context 'when logo width is larger than logo height' do
|
62
62
|
let(:logo_dimensions) do
|
63
63
|
{ width: 175, height: 150 }
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it 'returns the options with box size' do
|
67
67
|
expect(subject.options).to eq(width: 100, position: :center, vposition: :center)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context
|
71
|
+
context 'when logo height is larger than logo width' do
|
72
72
|
let(:logo_dimensions) do
|
73
73
|
{ width: 150, height: 175 }
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'returns the options with box size' do
|
77
77
|
expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
|
78
78
|
end
|
79
79
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Options do
|
4
|
-
it
|
4
|
+
it 'returns the default config set in the code' do
|
5
5
|
options = BrDanfe::DanfeLib::Options.new
|
6
|
-
expect(options.logo).to eq(
|
6
|
+
expect(options.logo).to eq('')
|
7
7
|
expect(options.logo_dimensions).to eq({})
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
custom_options = { logo:
|
10
|
+
it 'returns the config set in params' do
|
11
|
+
custom_options = { logo: '/fake/path/file.png', logo_dimensions: { width: 50, height: 50 } }
|
12
12
|
|
13
13
|
options = BrDanfe::DanfeLib::Options.new(custom_options)
|
14
|
-
expect(options.logo).to eq(
|
15
|
-
expect(options.logo_dimensions).to eq({ width: 50, height: 50})
|
14
|
+
expect(options.logo).to eq('/fake/path/file.png')
|
15
|
+
expect(options.logo_dimensions).to eq({ width: 50, height: 50 })
|
16
16
|
end
|
17
17
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Phone do
|
4
|
-
describe
|
5
|
-
context
|
6
|
-
it
|
7
|
-
phone =
|
8
|
-
expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq
|
4
|
+
describe '.format' do
|
5
|
+
context 'when phone have 10 digits' do
|
6
|
+
it 'returns a formated phone' do
|
7
|
+
phone = '1234567890'
|
8
|
+
expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq '(12) 3456-7890'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
phone =
|
15
|
-
expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq
|
12
|
+
context 'when phone have 11 digits' do
|
13
|
+
it 'returns a formated phone' do
|
14
|
+
phone = '12345678901'
|
15
|
+
expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq '(12) 34567-8901'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Plate do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
plate =
|
7
|
-
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq
|
4
|
+
describe '.format_plate' do
|
5
|
+
it 'returns a formated plate' do
|
6
|
+
plate = 'ABC1234'
|
7
|
+
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq 'ABC-1234'
|
8
8
|
end
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
plate =
|
13
|
-
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq
|
10
|
+
context 'when receive a mercosul plate' do
|
11
|
+
it 'returns a formated plate' do
|
12
|
+
plate = 'ABC1D23'
|
13
|
+
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq 'ABC-1D23'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Ticket do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
@@ -9,7 +9,7 @@ describe BrDanfe::DanfeLib::Ticket do
|
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
let(:xml_as_string) do
|
14
14
|
<<-eos
|
15
15
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -31,7 +31,7 @@ describe BrDanfe::DanfeLib::Ticket do
|
|
31
31
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'renders xml to the pdf' do
|
35
35
|
expect(File.exist?(output_pdf)).to be_falsey
|
36
36
|
|
37
37
|
pdf.render_file output_pdf
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Transp do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
@@ -9,7 +9,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
let(:xml_as_string) do
|
14
14
|
<<-eos
|
15
15
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -40,7 +40,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
40
40
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it 'renders xml to the pdf' do
|
44
44
|
expect(File.exist?(output_pdf)).to be_falsey
|
45
45
|
|
46
46
|
pdf.render_file output_pdf
|
@@ -48,7 +48,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
48
48
|
expect("#{base_dir}transp#render.pdf").to have_same_content_of file: output_pdf
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
51
|
+
context 'when modFrete is 0' do
|
52
52
|
let(:xml_as_string) do
|
53
53
|
<<-eos
|
54
54
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -70,7 +70,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context
|
73
|
+
context 'when modFrete is 1' do
|
74
74
|
let(:xml_as_string) do
|
75
75
|
<<-eos
|
76
76
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -92,7 +92,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
context
|
95
|
+
context 'when modFrete is 2' do
|
96
96
|
let(:xml_as_string) do
|
97
97
|
<<-eos
|
98
98
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -114,7 +114,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
context
|
117
|
+
context 'when modFrete is 3' do
|
118
118
|
let(:xml_as_string) do
|
119
119
|
<<-eos
|
120
120
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -136,7 +136,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
context
|
139
|
+
context 'when modFrete is 4' do
|
140
140
|
let(:xml_as_string) do
|
141
141
|
<<-eos
|
142
142
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -158,7 +158,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
context
|
161
|
+
context 'when modFrete is 9' do
|
162
162
|
let(:xml_as_string) do
|
163
163
|
<<-eos
|
164
164
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Vol do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
@@ -9,7 +9,7 @@ describe BrDanfe::DanfeLib::Vol do
|
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
let(:xml_as_string) do
|
14
14
|
<<-eos
|
15
15
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -50,7 +50,7 @@ describe BrDanfe::DanfeLib::Vol do
|
|
50
50
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it 'renders xml to the pdf' do
|
54
54
|
expect(File.exist?(output_pdf)).to be_falsey
|
55
55
|
|
56
56
|
pdf.render_file output_pdf
|
@@ -58,11 +58,11 @@ describe BrDanfe::DanfeLib::Vol do
|
|
58
58
|
expect("#{base_dir}vol#render.pdf").to have_same_content_of file: output_pdf
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it 'returns the quantity of volumes' do
|
62
62
|
expect(subject.render).to eq 3
|
63
63
|
end
|
64
64
|
|
65
|
-
context
|
65
|
+
context 'when any <vol> tag is found' do
|
66
66
|
let(:xml_as_string) do
|
67
67
|
<<-eos
|
68
68
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -74,7 +74,7 @@ describe BrDanfe::DanfeLib::Vol do
|
|
74
74
|
eos
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
77
|
+
it 'renders blank boxes' do
|
78
78
|
expect(File.exist?(output_pdf)).to be_falsey
|
79
79
|
|
80
80
|
pdf.render_file output_pdf
|