br_danfe 0.16.0 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -8
  3. data/.github/dependabot.yml +19 -0
  4. data/.rubocop.yml +24 -11
  5. data/Gemfile.lock +41 -35
  6. data/Guardfile +3 -1
  7. data/bin/_guard-core +29 -0
  8. data/bin/guard +29 -0
  9. data/br_danfe.gemspec +7 -6
  10. data/lib/br_danfe/danfe_lib/nfce.rb +11 -9
  11. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +1 -1
  12. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +2 -2
  13. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +30 -16
  14. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +3 -3
  15. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +3 -3
  16. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +44 -53
  17. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +1 -1
  18. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +16 -15
  19. data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
  20. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
  21. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +6 -7
  22. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
  23. data/lib/br_danfe/helper.rb +1 -1
  24. data/lib/br_danfe/mdfe.rb +1 -1
  25. data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +1 -1
  26. data/lib/br_danfe/mdfe_lib/fisco_control.rb +6 -25
  27. data/lib/br_danfe/mdfe_lib/header.rb +7 -8
  28. data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +1 -1
  29. data/lib/br_danfe/mdfe_lib/notes.rb +1 -1
  30. data/lib/br_danfe/qr_code.rb +1 -2
  31. data/lib/br_danfe/version.rb +1 -1
  32. data/lib/br_danfe.rb +2 -2
  33. data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +3 -2
  34. data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +6 -4
  35. data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +2 -2
  36. data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +2 -2
  37. data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +2 -2
  38. data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +10 -10
  39. data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +12 -12
  40. data/spec/br_danfe/danfe_lib/nfce_spec.rb +2 -1
  41. data/spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb +4 -4
  42. data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +178 -178
  43. data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +274 -274
  44. data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +77 -77
  45. data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +23 -23
  46. data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +55 -37
  47. data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +34 -34
  48. data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +19 -19
  49. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +237 -237
  50. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +3 -2
  51. data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +16 -16
  52. data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +13 -13
  53. data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +76 -76
  54. data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +40 -40
  55. data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +118 -118
  56. data/spec/br_danfe/danfe_spec.rb +2 -2
  57. data/spec/br_danfe/helper_spec.rb +15 -15
  58. data/spec/br_danfe/mdfe_lib/document_spec.rb +2 -2
  59. data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +21 -7
  60. data/spec/br_danfe/mdfe_lib/header_spec.rb +27 -18
  61. data/spec/br_danfe/mdfe_lib/notes_spec.rb +5 -5
  62. data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +1 -1
  63. data/spec/br_danfe/mdfe_spec.rb +4 -5
  64. data/spec/br_danfe/qr_code_spec.rb +4 -13
  65. data/spec/br_danfe/xml_spec.rb +6 -6
  66. data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
  67. data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
  68. data/spec/fixtures/nfce/lib/document#render.pdf +12 -23
  69. data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +0 -0
  70. data/spec/fixtures/nfce/lib/footer#render.pdf +0 -0
  71. data/spec/fixtures/nfce/lib/header#render-homologation.pdf +0 -0
  72. data/spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf +0 -0
  73. data/spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf +0 -0
  74. data/spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf +0 -0
  75. data/spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf +0 -0
  76. data/spec/fixtures/nfce/lib/key#render.pdf +0 -0
  77. data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +0 -0
  78. data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +0 -0
  79. data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +0 -0
  80. data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +0 -0
  81. data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +0 -0
  82. data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +2 -2
  83. data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +1 -1
  84. data/spec/fixtures/nfce/lib/recipient#render-company.pdf +0 -0
  85. data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +0 -0
  86. data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +0 -0
  87. data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +0 -0
  88. data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +0 -0
  89. data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +0 -0
  90. data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +0 -0
  91. data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +0 -0
  92. data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +0 -0
  93. data/spec/fixtures/nfce/lib/total_list#render.pdf +0 -0
  94. data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +568 -447
  95. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  96. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  97. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  98. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  99. data/spec/fixtures/nfe/lib/emit_header#render-nfe_key.pdf +945 -0
  100. data/spec/spec_helper.rb +1 -1
  101. metadata +38 -16
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe BrDanfe::Danfe do
4
4
  let(:xml) do
5
- <<-eos
5
+ <<~XML
6
6
  <nfeProc>
7
7
  <NFe>
8
8
  <infNFe>
@@ -17,7 +17,7 @@ describe BrDanfe::Danfe do
17
17
  </infNFe>
18
18
  </NFe>
19
19
  </nfeProc>
20
- eos
20
+ XML
21
21
  end
22
22
 
23
23
  subject { described_class.new(xml) }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe BrDanfe::Helper do
4
4
  describe '.no_fiscal_value?' do
5
5
  let(:xml_homologation) do
6
- xml = <<-eos
6
+ xml = <<~XML
7
7
  <nfeProc>
8
8
  <NFe>
9
9
  <infNFe>
@@ -18,25 +18,25 @@ describe BrDanfe::Helper do
18
18
  </protNFe>
19
19
  </NFe>
20
20
  </nfeProc>
21
- eos
21
+ XML
22
22
 
23
23
  Nokogiri::XML(xml)
24
24
  end
25
25
 
26
26
  let(:xml_unauthorized) do
27
- xml = <<-eos
27
+ xml = <<~XML
28
28
  <nfeProc>
29
29
  <protNFe>
30
30
  <infProt></infProt>
31
31
  </protNFe>
32
32
  </nfeProc>
33
- eos
33
+ XML
34
34
 
35
35
  Nokogiri::XML(xml)
36
36
  end
37
37
 
38
38
  let(:xml_authorized) do
39
- xml = <<-eos
39
+ xml = <<~XML
40
40
  <nfeProc>
41
41
  <NFe>
42
42
  <infNFe>
@@ -51,7 +51,7 @@ describe BrDanfe::Helper do
51
51
  </infProt>
52
52
  </protNFe>
53
53
  </nfeProc>
54
- eos
54
+ XML
55
55
 
56
56
  Nokogiri::XML(xml)
57
57
  end
@@ -78,13 +78,13 @@ describe BrDanfe::Helper do
78
78
  describe '.unauthorized?' do
79
79
  context 'when XML is unauthorized' do
80
80
  let(:xml_unauthorized) do
81
- xml = <<-eos
81
+ xml = <<~XML
82
82
  <nfeProc>
83
83
  <protNFe>
84
84
  <infProt></infProt>
85
85
  </protNFe>
86
86
  </nfeProc>
87
- eos
87
+ XML
88
88
 
89
89
  Nokogiri::XML(xml)
90
90
  end
@@ -96,7 +96,7 @@ describe BrDanfe::Helper do
96
96
 
97
97
  context 'when XML is authorized' do
98
98
  let(:xml_authorized) do
99
- xml = <<-eos
99
+ xml = <<~XML
100
100
  <nfeProc>
101
101
  <protNFe>
102
102
  <infProt>
@@ -104,7 +104,7 @@ describe BrDanfe::Helper do
104
104
  </infProt>
105
105
  </protNFe>
106
106
  </nfeProc>
107
- eos
107
+ XML
108
108
 
109
109
  Nokogiri::XML(xml)
110
110
  end
@@ -118,7 +118,7 @@ describe BrDanfe::Helper do
118
118
  describe '.homologation?' do
119
119
  context 'when tpAmb is equal to "2"' do
120
120
  let(:xml_homologation) do
121
- xml = <<-eos
121
+ xml = <<~XML
122
122
  <nfeProc>
123
123
  <NFe>
124
124
  <infNFe>
@@ -128,7 +128,7 @@ describe BrDanfe::Helper do
128
128
  </infNFe>
129
129
  </NFe>
130
130
  </nfeProc>
131
- eos
131
+ XML
132
132
 
133
133
  Nokogiri::XML(xml)
134
134
  end
@@ -140,7 +140,7 @@ describe BrDanfe::Helper do
140
140
 
141
141
  context 'when tpAmb is different to "2"' do
142
142
  let(:xml_production) do
143
- xml = <<-eos
143
+ xml = <<~XML
144
144
  <nfeProc>
145
145
  <NFe>
146
146
  <infNFe>
@@ -150,7 +150,7 @@ describe BrDanfe::Helper do
150
150
  </infNFe>
151
151
  </NFe>
152
152
  </nfeProc>
153
- eos
153
+ XML
154
154
 
155
155
  Nokogiri::XML(xml)
156
156
  end
@@ -214,7 +214,7 @@ describe BrDanfe::Helper do
214
214
  end
215
215
 
216
216
  describe 'when has timezone' do
217
- it'returns the formated string with the timezone' do
217
+ it 'returns the formated string with the timezone' do
218
218
  expect(described_class.format_datetime('2013-10-18T13:54:04-03:00', with_time_zone: true)).to eql '18/10/2013 13:54:04-03:00'
219
219
  end
220
220
  end
@@ -7,13 +7,13 @@ describe BrDanfe::MdfeLib::Document do
7
7
  describe '#method_missing' do
8
8
  context 'when prawn has the method' do
9
9
  it 'does not throws an error' do
10
- expect { subject.text }.not_to raise_error NameError
10
+ expect(subject).to respond_to :text
11
11
  end
12
12
  end
13
13
 
14
14
  context 'when prawn does not have the method' do
15
15
  it 'throws an error' do
16
- expect { subject.any_method }.to raise_error NameError
16
+ expect { subject.non_existent_method }.to raise_error NameError
17
17
  end
18
18
  end
19
19
  end
@@ -27,13 +27,11 @@ describe BrDanfe::MdfeLib::FiscoControl do
27
27
  end
28
28
 
29
29
  describe '#generate' do
30
- after { File.delete(output_pdf) if File.exist?(output_pdf) }
30
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
31
31
 
32
32
  it 'generates the title' do
33
- title = 'CONTROLE DO FISCO'
34
-
35
33
  subject.generate
36
- expect(pdf_text).to include title
34
+ expect(pdf_text).to include 'CONTROLE DO FISCO'
37
35
  end
38
36
 
39
37
  it 'generates the bar code' do
@@ -46,10 +44,26 @@ describe BrDanfe::MdfeLib::FiscoControl do
46
44
  end
47
45
 
48
46
  it 'generates the nfe key' do
49
- nfe_key = "Chave de Acesso\n32210717781119000141580010000001211000000003"
50
-
51
47
  subject.generate
52
- expect(pdf_text).to include nfe_key
48
+ expect(pdf_text).to include "Chave de Acesso\n32210717781119000141580010000001211000000003"
49
+ end
50
+
51
+ context 'when the XML does not have protMDFe tag' do
52
+ let(:xml_as_string) do
53
+ <<~XML
54
+ <?xml version="1.0" encoding="UTF-8"?>
55
+ <mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00"></mdfeProc>
56
+ XML
57
+ end
58
+
59
+ it 'does not generate the bar code and the nfe key' do
60
+ expect(File.exist?(output_pdf)).to be false
61
+
62
+ subject.generate
63
+ pdf.render_file output_pdf
64
+
65
+ expect("#{base_dir}fisco_control#without-barcode.pdf").to have_same_content_of file: output_pdf
66
+ end
53
67
  end
54
68
  end
55
69
  end
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BrDanfe::MdfeLib::Header do
4
+ let(:qr_code_mdfe) do
5
+ url = 'https://dfe-portal.svrs.rs.gov.br/mdfe/QRCode?chMDFe=32210717781119000141580010000001211000000003&amp;tpAmb=1'
6
+ "<qrCodMDFe>#{url}</qrCodMDFe>"
7
+ end
4
8
  let(:xml_as_string) do
5
9
  <<~XML
6
10
  <?xml version="1.0" encoding="UTF-8"?>
@@ -32,19 +36,14 @@ describe BrDanfe::MdfeLib::Header do
32
36
  </emit>
33
37
  </infMDFe>
34
38
  <infMDFeSupl>
35
- <qrCodMDFe>https://dfe-portal.svrs.rs.gov.br/mdfe/QRCode?chMDFe=32210717781119000141580010000001211000000003&amp;tpAmb=1</qrCodMDFe>
39
+ #{qr_code_mdfe}
36
40
  </infMDFeSupl>
37
41
  </MDFe>
38
42
  </mdfeProc>
39
43
  XML
40
44
  end
41
-
42
45
  let(:pdf) { BrDanfe::MdfeLib::Document.new }
43
46
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
44
-
45
- let(:base_dir) { './spec/fixtures/mdfe/lib/' }
46
- let(:output_pdf) { "#{base_dir}output.pdf" }
47
-
48
47
  let(:logo_dimensions) { { width: 100, height: 100 } }
49
48
  let(:logo) { 'spec/fixtures/logo.png' }
50
49
 
@@ -54,9 +53,12 @@ describe BrDanfe::MdfeLib::Header do
54
53
  PDF::Inspector::Text.analyze(pdf.render).strings.join("\n")
55
54
  end
56
55
 
57
- after { File.delete(output_pdf) if File.exist?(output_pdf) }
58
-
59
56
  describe '#generate' do
57
+ let(:base_dir) { './spec/fixtures/mdfe/lib/' }
58
+ let(:output_pdf) { "#{base_dir}output.pdf" }
59
+
60
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
61
+
60
62
  it 'generates the emitter informations' do
61
63
  emitter_name = 'VENTURIM AGROCRIATIVA LTDA EPP'
62
64
  emitter_address = "RODOVIA ES 473 KM 13, nº 0\nVENDA NOVA DO IMIGRANTE - ES CEP 29.375-000"
@@ -72,15 +74,12 @@ describe BrDanfe::MdfeLib::Header do
72
74
  expect(pdf_text).to include emitter_ie
73
75
  end
74
76
 
75
- it'generates the DAMDFE title' do
76
- title = "DAMDFE\n - Documento Auxiliar de Manifesto Eletrônico de Documentos Fiscais"
77
-
77
+ it 'generates the DAMDFE title' do
78
78
  subject.generate
79
-
80
- expect(pdf_text).to include title
79
+ expect(pdf_text).to include "DAMDFE\n - Documento Auxiliar de Manifesto Eletrônico de Documentos Fiscais"
81
80
  end
82
81
 
83
- it 'generates the qr code' do
82
+ it 'generates the QR-code' do
84
83
  expect(File.exist?(output_pdf)).to be false
85
84
 
86
85
  subject.generate
@@ -89,12 +88,22 @@ describe BrDanfe::MdfeLib::Header do
89
88
  expect("#{base_dir}header#render-qr-code.pdf").to have_same_content_of file: output_pdf
90
89
  end
91
90
 
92
- it 'generates the company CNPJ' do
93
- cnpj = "CNPJ: \n17781119000141"
91
+ context 'if the QR-code URL is not present' do
92
+ let(:qr_code_mdfe) { '<qrCodMDFe></qrCodMDFe>' }
94
93
 
95
- subject.generate
94
+ it 'does not generates the QR-code' do
95
+ expect(File.exist?(output_pdf)).to be false
96
+
97
+ subject.generate
98
+ pdf.render_file output_pdf
99
+
100
+ expect("#{base_dir}header#render-without-qr-code.pdf").to have_same_content_of file: output_pdf
101
+ end
102
+ end
96
103
 
97
- expect(pdf_text).to include cnpj
104
+ it 'generates the company CNPJ' do
105
+ subject.generate
106
+ expect(pdf_text).to include "CNPJ: \n17781119000141"
98
107
  end
99
108
 
100
109
  describe 'logo' do
@@ -22,9 +22,6 @@ describe BrDanfe::MdfeLib::Notes do
22
22
  XML
23
23
  end
24
24
 
25
- let(:base_dir) { './spec/fixtures/mdfe/lib/' }
26
- let(:output_pdf) { "#{base_dir}output.pdf" }
27
-
28
25
  let(:pdf) { BrDanfe::MdfeLib::Document.new }
29
26
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
30
27
 
@@ -37,6 +34,11 @@ describe BrDanfe::MdfeLib::Notes do
37
34
  before { pdf.move_cursor_to 345 }
38
35
 
39
36
  describe '#generate' do
37
+ let(:base_dir) { './spec/fixtures/mdfe/lib/' }
38
+ let(:output_pdf) { "#{base_dir}output.pdf" }
39
+
40
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
41
+
40
42
  it 'generates the title' do
41
43
  title = 'Observações'
42
44
 
@@ -76,8 +78,6 @@ describe BrDanfe::MdfeLib::Notes do
76
78
  expect(pdf_text).not_to include taxpayer_information
77
79
  end
78
80
 
79
- after { File.delete(output_pdf) if File.exist?(output_pdf) }
80
-
81
81
  it 'creates a new page if aditional information do not fit on first page' do
82
82
  expect(File.exist?(output_pdf)).to be false
83
83
 
@@ -53,7 +53,7 @@ describe BrDanfe::MdfeLib::Totalizer do
53
53
  expect(pdf_text).to include total_weight
54
54
  end
55
55
 
56
- it'generates the totalizer title' do
56
+ it 'generates the totalizer title' do
57
57
  title = 'Modelo Rodoviário de Carga'
58
58
 
59
59
  subject.generate
@@ -4,12 +4,11 @@ describe BrDanfe::Mdfe do
4
4
  let(:base_dir) { './spec/fixtures/mdfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:xml_as_string) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe.xml') }
8
-
9
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe.xml') }
10
8
 
11
9
  subject { described_class.new(xml) }
12
- after { File.delete(output_pdf) if File.exist?(output_pdf) }
10
+
11
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
13
12
 
14
13
  before do
15
14
  subject.logo_options.logo_dimensions = { width: 100, height: 100 }
@@ -34,7 +33,7 @@ describe BrDanfe::Mdfe do
34
33
  end
35
34
 
36
35
  context 'when MDF-e has multiple pages' do
37
- let(:xml_as_string) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml') }
36
+ let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml') }
38
37
 
39
38
  it 'renders the header and the identification on each page' do
40
39
  expect(File.exist?(output_pdf)).to be false
@@ -11,23 +11,14 @@ describe BrDanfe::QrCode do
11
11
  )
12
12
  end
13
13
 
14
- let(:xml) do
15
- xml = <<-eos
16
- <infNFeSupl>
17
- <qrCode><![CDATA[http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13]]></qrCode>
18
- <urlChave>www.sefaz.am.gov.br/nfce/consulta</urlChave>
19
- </infNFeSupl>
20
- eos
21
-
22
- BrDanfe::XML.new(xml)
14
+ let(:qr_code_url) do
15
+ 'http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13'
23
16
  end
24
17
 
25
- subject { described_class.new(pdf: pdf, xml: xml, qr_code_tag: xml['qrCode'], box_size: 3.cm) }
18
+ subject { described_class.new(pdf: pdf, qr_code_tag: qr_code_url, box_size: 3.cm) }
26
19
 
27
20
  describe '#render' do
28
- before do
29
- File.delete(output_pdf) if File.exist?(output_pdf)
30
- end
21
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
31
22
 
32
23
  it 'renders qr-code to the pdf' do
33
24
  expect(File.exist?(output_pdf)).to be_falsey
@@ -6,12 +6,12 @@ describe BrDanfe::XML do
6
6
  describe '#version_is_310_or_newer?' do
7
7
  describe "when xml's version is equal 3.10" do
8
8
  let(:xml_as_string) do
9
- <<-eos
9
+ <<~XML
10
10
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
11
11
  <infNFe versao="3.10" Id="NFe35150162013294000143550010000000011000000017">
12
12
  </infNFe>
13
13
  </NFe>
14
- eos
14
+ XML
15
15
  end
16
16
 
17
17
  it 'returns true' do
@@ -21,12 +21,12 @@ describe BrDanfe::XML do
21
21
 
22
22
  describe "when xml's version is greather 3.10" do
23
23
  let(:xml_as_string) do
24
- <<-eos
24
+ <<~XML
25
25
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
26
26
  <infNFe versao="4.00" Id="NFe35150162013294000143550010000000011000000017">
27
27
  </infNFe>
28
28
  </NFe>
29
- eos
29
+ XML
30
30
  end
31
31
 
32
32
  it 'returns true' do
@@ -36,12 +36,12 @@ describe BrDanfe::XML do
36
36
 
37
37
  describe "when xml's version is minor that 3.10" do
38
38
  let(:xml_as_string) do
39
- <<-eos
39
+ <<~XML
40
40
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
41
41
  <infNFe versao="2.00" Id="NFe35131260891033000109550010000000011000000016">
42
42
  </infNFe>
43
43
  </NFe>
44
- eos
44
+ XML
45
45
  end
46
46
 
47
47
  it 'returns false' do
@@ -13,20 +13,18 @@ endobj
13
13
  3 0 obj
14
14
  << /Type /Pages
15
15
  /Count 2
16
- /Kids [5 0 R 8 0 R]
16
+ /Kids [5 0 R 7 0 R]
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 55
20
+ << /Length 38
21
21
  >>
22
22
  stream
23
23
  q
24
24
  0.3 w
25
25
 
26
26
  BT
27
- 8.50394 38.74569 Td
28
- /F1.0 6 Tf
29
- <> Tj
27
+ 8.50394 38.36169 Td
30
28
  ET
31
29
 
32
30
  Q
@@ -43,19 +41,11 @@ endobj
43
41
  /ArtBox [0 0 226.77165 51.02362]
44
42
  /Contents 4 0 R
45
43
  /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
46
- /Font << /F1.0 6 0 R
47
- >>
44
+ /Font << >>
48
45
  >>
49
46
  >>
50
47
  endobj
51
48
  6 0 obj
52
- << /Type /Font
53
- /Subtype /Type1
54
- /BaseFont /Courier
55
- /Encoding /WinAnsiEncoding
56
- >>
57
- endobj
58
- 7 0 obj
59
49
  << /Length 10
60
50
  >>
61
51
  stream
@@ -65,7 +55,7 @@ Q
65
55
 
66
56
  endstream
67
57
  endobj
68
- 8 0 obj
58
+ 7 0 obj
69
59
  << /Type /Page
70
60
  /Parent 3 0 R
71
61
  /MediaBox [0 0 226.77165 51.02362]
@@ -73,27 +63,26 @@ endobj
73
63
  /BleedBox [0 0 226.77165 51.02362]
74
64
  /TrimBox [0 0 226.77165 51.02362]
75
65
  /ArtBox [0 0 226.77165 51.02362]
76
- /Contents 7 0 R
66
+ /Contents 6 0 R
77
67
  /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
78
68
  >>
79
69
  >>
80
70
  endobj
81
71
  xref
82
- 0 9
72
+ 0 8
83
73
  0000000000 65535 f
84
74
  0000000015 00000 n
85
75
  0000000109 00000 n
86
76
  0000000158 00000 n
87
77
  0000000221 00000 n
88
- 0000000326 00000 n
89
- 0000000647 00000 n
90
- 0000000742 00000 n
91
- 0000000802 00000 n
78
+ 0000000309 00000 n
79
+ 0000000618 00000 n
80
+ 0000000678 00000 n
92
81
  trailer
93
- << /Size 9
82
+ << /Size 8
94
83
  /Root 2 0 R
95
84
  /Info 1 0 R
96
85
  >>
97
86
  startxref
98
- 1099
87
+ 975
99
88
  %%EOF
Binary file
@@ -64,7 +64,7 @@
64
64
  <prod>
65
65
  <cProd>1173</cProd>
66
66
  <cEAN>568754456745</cEAN>
67
- <xProd>Abraçadeira with a larger name with line breaks</xProd>
67
+ <xProd>Abraçadeira de metal with a larger name truncated</xProd>
68
68
  <NCM>01022990</NCM>
69
69
  <CFOP>5101</CFOP>
70
70
  <uCom>UN</uCom>
@@ -150,7 +150,7 @@
150
150
  <prod>
151
151
  <cProd>1173</cProd>
152
152
  <cEAN>568754456745</cEAN>
153
- <xProd>Abraçadeira with a larger name with line breaks</xProd>
153
+ <xProd>Abraçadeira de metal with a larger name truncated</xProd>
154
154
  <NCM>01022990</NCM>
155
155
  <CFOP>5101</CFOP>
156
156
  <uCom>UN</uCom>
@@ -64,7 +64,7 @@
64
64
  <prod>
65
65
  <cProd>1173</cProd>
66
66
  <cEAN>568754456745</cEAN>
67
- <xProd>Abraçadeira with a larger name with line breaks</xProd>
67
+ <xProd>Abraçadeira de metal with a larger name truncated</xProd>
68
68
  <NCM>01022990</NCM>
69
69
  <CFOP>5101</CFOP>
70
70
  <uCom>UN</uCom>