br_danfe 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -25
  3. data/Gemfile.lock +1 -1
  4. data/README.md +5 -5
  5. data/lib/br_danfe.rb +0 -1
  6. data/lib/br_danfe/danfe.rb +6 -90
  7. data/lib/br_danfe/danfe_lib/base.rb +33 -0
  8. data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
  9. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
  10. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
  11. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
  12. data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
  13. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
  14. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
  15. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
  16. data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
  17. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
  18. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
  19. data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
  20. data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
  21. data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
  22. data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
  23. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
  24. data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
  25. data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
  26. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
  27. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
  28. data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
  29. data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
  30. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +109 -0
  31. data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
  32. data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
  33. data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
  34. data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
  35. data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
  36. data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
  37. data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
  38. data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
  39. data/lib/br_danfe/helper.rb +8 -0
  40. data/lib/br_danfe/version.rb +1 -1
  41. data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
  42. data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
  43. data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
  44. data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
  45. data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
  46. data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
  47. data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
  48. data/spec/{features → br_danfe}/cce_spec.rb +0 -0
  49. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
  50. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
  51. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
  52. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
  53. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
  54. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
  55. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
  56. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
  57. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
  58. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
  59. data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
  60. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
  61. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
  62. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
  63. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
  64. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
  65. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
  66. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
  67. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
  68. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
  69. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +2 -2
  70. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
  71. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
  72. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
  73. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
  74. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
  75. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
  76. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
  77. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
  78. data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
  79. data/spec/br_danfe/danfe_spec.rb +35 -0
  80. data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
  81. data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
  82. data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
  83. data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
  84. data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
  85. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  86. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
  87. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  88. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
  89. data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
  90. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  91. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  92. metadata +82 -75
  93. data/lib/br_danfe/danfe_lib/cep.rb +0 -9
  94. data/lib/br_danfe/danfe_lib/consts.rb +0 -6
  95. data/lib/br_danfe/danfe_lib/cst.rb +0 -32
  96. data/lib/br_danfe/danfe_lib/dest.rb +0 -94
  97. data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
  98. data/lib/br_danfe/danfe_lib/document.rb +0 -140
  99. data/lib/br_danfe/danfe_lib/dup.rb +0 -53
  100. data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
  101. data/lib/br_danfe/danfe_lib/helper.rb +0 -61
  102. data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
  103. data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
  104. data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
  105. data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
  106. data/lib/br_danfe/danfe_lib/phone.rb +0 -13
  107. data/lib/br_danfe/danfe_lib/plate.rb +0 -9
  108. data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
  109. data/lib/br_danfe/danfe_lib/transp.rb +0 -56
  110. data/lib/br_danfe/danfe_lib/vol.rb +0 -42
  111. data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
  112. data/lib/br_danfe/danfe_nfce.rb +0 -43
  113. data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
  114. data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
  115. data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
  116. data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
  117. data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
  118. data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
  119. data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
  120. data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
  121. data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
  122. data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
  123. data/spec/features/danfe_nfce_spec.rb +0 -31
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeNfceLib::TotalList do
3
+ describe BrDanfe::DanfeLib::NfceLib::TotalList do
4
4
  let(:base_dir) { './spec/fixtures/nfce/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
8
8
  let(:payment_xml) do
9
9
  <<-eos
10
10
  <pag>
@@ -24,7 +24,7 @@ describe BrDanfe::DanfeNfceLib::TotalList do
24
24
  eos
25
25
  end
26
26
  let(:xml_as_string) do
27
- xml = <<-eos
27
+ <<-eos
28
28
  <nfeProc>
29
29
  <NFe>
30
30
  <infNFe>
@@ -64,7 +64,7 @@ describe BrDanfe::DanfeNfceLib::TotalList do
64
64
 
65
65
  describe 'about totals' do
66
66
  let(:xml_as_string) do
67
- xml = <<-eos
67
+ <<-eos
68
68
  <nfeProc>
69
69
  <NFe>
70
70
  <infNFe>
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrDanfe::DanfeLib::Nfce do
4
+ let(:output_pdf) { "#{base_dir}output.pdf" }
5
+ let(:base_dir) { './spec/fixtures/nfce/v4.00/' }
6
+ let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce.xml")) }
7
+
8
+ subject { described_class.new xml }
9
+
10
+ before do
11
+ subject.options.logo = 'spec/fixtures/logo.png'
12
+ subject.options.logo_dimensions = { width: 100, height: 100 }
13
+ end
14
+
15
+ describe '#render_pdf' do
16
+ it 'renders the NFC-e pdf' do
17
+ expected = IO.binread("#{base_dir}rendered_nfce.fixture.pdf")
18
+ expect(subject.render_pdf).to eq expected
19
+ end
20
+ end
21
+
22
+ describe '#save_pdf' do
23
+ before { File.delete(output_pdf) if File.exist?(output_pdf) }
24
+ after { File.delete(output_pdf) if File.exist?(output_pdf) }
25
+
26
+ it 'saves the NFC-e as pdf' do
27
+ expect(File.exist?(output_pdf)).to be_falsey
28
+ subject.save_pdf output_pdf
29
+
30
+ expect("#{base_dir}saved_nfce.fixture.pdf").to have_same_content_of file: output_pdf
31
+ end
32
+
33
+ context 'when nfc-e is unauthorized' do
34
+ context 'when nfc-e is in homologation environment' do
35
+ let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce-unauthorized-hom.xml")) }
36
+
37
+ it 'render watermark at pdf' do
38
+ expect(File.exist?(output_pdf)).to be_falsey
39
+ subject.save_pdf output_pdf
40
+
41
+ expect("#{base_dir}nfce-unauthorized-hom.fixture.pdf").to have_same_content_of file: output_pdf
42
+ end
43
+ end
44
+
45
+ context 'when nfc-e is in production environment' do
46
+ let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce-unauthorized-prod.xml")) }
47
+
48
+ it 'render watermark at pdf' do
49
+ expect(File.exist?(output_pdf)).to be_falsey
50
+ subject.save_pdf output_pdf
51
+
52
+ expect("#{base_dir}nfce-unauthorized-prod.fixture.pdf").to have_same_content_of file: output_pdf
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Cep do
3
+ describe BrDanfe::DanfeLib::NfeLib::Cep do
4
4
  describe '.format' do
5
5
  it 'returns a formated CEP' do
6
6
  cep = '12345678'
7
- expect(BrDanfe::DanfeLib::Cep.format(cep)).to eq '12.345-678'
7
+ expect(BrDanfe::DanfeLib::NfeLib::Cep.format(cep)).to eq '12.345-678'
8
8
  end
9
9
  end
10
10
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Cst do
3
+ describe BrDanfe::DanfeLib::NfeLib::Cst do
4
4
  let(:xml_cst) do
5
5
  xml = <<-eos
6
6
  <imposto>
@@ -38,13 +38,13 @@ describe BrDanfe::DanfeLib::Cst do
38
38
  describe '.to_danfe' do
39
39
  context 'when CST' do
40
40
  it 'returns origin + CST' do
41
- expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_cst)).to eq '500'
41
+ expect(BrDanfe::DanfeLib::NfeLib::Cst.to_danfe(xml_cst)).to eq '500'
42
42
  end
43
43
  end
44
44
 
45
45
  context 'when CSOSN' do
46
46
  it 'returns origin + CSOSN' do
47
- expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_csosn)).to eq '4102'
47
+ expect(BrDanfe::DanfeLib::NfeLib::Cst.to_danfe(xml_csosn)).to eq '4102'
48
48
  end
49
49
  end
50
50
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Dest do
3
+ describe BrDanfe::DanfeLib::NfeLib::Dest do
4
4
  let(:path_of_expected_pdf) { './spec/fixtures/nfe/lib/output.pdf' }
5
5
 
6
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
6
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
7
7
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
8
8
 
9
9
  subject { described_class.new(pdf, xml) }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::DetBody do
3
+ describe BrDanfe::DanfeLib::NfeLib::DetBody do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
 
10
10
  let(:xml_as_string) do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Document do
3
+ describe BrDanfe::DanfeLib::NfeLib::Document do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Dup do
3
+ describe BrDanfe::DanfeLib::NfeLib::Dup do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::EmitHeader do
3
+ describe BrDanfe::DanfeLib::NfeLib::EmitHeader do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
  let(:logo) { 'spec/fixtures/logo.png' }
10
10
 
11
- subject { described_class.new(pdf, xml, logo, { width: 100, height: 100 }) }
11
+ subject { described_class.new(pdf, xml, logo, width: 100, height: 100) }
12
12
 
13
13
  describe '#render' do
14
14
  let(:xml_as_string) do
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Helper do
3
+ describe BrDanfe::DanfeLib::NfeLib::Helper do
4
4
  describe '.format_date' do
5
5
  it 'returns a formated string' do
6
6
  string = '2013-10-18T13:54:04'
7
- expect(BrDanfe::DanfeLib::Helper.format_date(string)).to eq '18/10/2013'
7
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.format_date(string)).to eq '18/10/2013'
8
8
  end
9
9
 
10
10
  describe 'when the source is blank' do
11
11
  it 'is empty' do
12
- expect(BrDanfe::DanfeLib::Helper.format_date('')).to eq ''
12
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.format_date('')).to eq ''
13
13
  end
14
14
  end
15
15
  end
@@ -19,7 +19,7 @@ describe BrDanfe::DanfeLib::Helper do
19
19
  let(:param) { '2013-10-18T16:54:04-03:00' }
20
20
 
21
21
  it 'is a formated time string in localtime' do
22
- expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq '16:54:04'
22
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.format_time(param)).to eq '16:54:04'
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe BrDanfe::DanfeLib::Helper do
27
27
  let(:param) { '14:23:02' }
28
28
 
29
29
  it 'is a formated time string' do
30
- expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq '14:23:02'
30
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.format_time(param)).to eq '14:23:02'
31
31
  end
32
32
  end
33
33
 
@@ -35,93 +35,19 @@ describe BrDanfe::DanfeLib::Helper do
35
35
  let(:param) { '' }
36
36
 
37
37
  it 'is empty' do
38
- expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq ''
39
- end
40
- end
41
- end
42
-
43
- describe '.no_fiscal_value?' do
44
- let(:xml_homologation) do
45
- xml = <<-eos
46
- <nfeProc>
47
- <NFe>
48
- <infNFe>
49
- <ide>
50
- <tpAmb>2</tpAmb>
51
- </ide>
52
- </infNFe>
53
- <protNFe>
54
- <infProt>
55
- <dhRecbto>2011-10-29T14:37:09</dhRecbto>
56
- </infProt>
57
- </protNFe>
58
- </NFe>
59
- </nfeProc>
60
- eos
61
-
62
- Nokogiri::XML(xml)
63
- end
64
-
65
- let(:xml_unauthorized) do
66
- xml = <<-eos
67
- <nfeProc>
68
- <protNFe>
69
- <infProt></infProt>
70
- </protNFe>
71
- </nfeProc>
72
- eos
73
-
74
- Nokogiri::XML(xml)
75
- end
76
-
77
- let(:xml_authorized) do
78
- xml = <<-eos
79
- <nfeProc>
80
- <NFe>
81
- <infNFe>
82
- <ide>
83
- <tpAmb>1</tpAmb>
84
- </ide>
85
- </infNFe>
86
- </NFe>
87
- <protNFe>
88
- <infProt>
89
- <dhRecbto>2011-10-29T14:37:09</dhRecbto>
90
- </infProt>
91
- </protNFe>
92
- </nfeProc>
93
- eos
94
-
95
- Nokogiri::XML(xml)
96
- end
97
-
98
- context 'when XML is unauthorized' do
99
- it 'returns true' do
100
- expect(BrDanfe::DanfeLib::Helper.no_fiscal_value?(xml_unauthorized)).to eq true
101
- end
102
- end
103
-
104
- context 'when XML is in homologation environment' do
105
- it 'returns true' do
106
- expect(BrDanfe::DanfeLib::Helper.no_fiscal_value?(xml_homologation)).to eq true
107
- end
108
- end
109
-
110
- context 'when XML is authorized' do
111
- it 'returns false' do
112
- expect(BrDanfe::DanfeLib::Helper.no_fiscal_value?(xml_authorized)).to eq false
38
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.format_time(param)).to eq ''
113
39
  end
114
40
  end
115
41
  end
116
42
 
117
43
  describe '.address_is_too_big' do
118
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
44
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
119
45
 
120
46
  context 'when the address is too big for the street field at DANFE' do
121
47
  let(:address) { 'Rua do governo do estado 1125 - Em anexo ao super mercado maior do bairro' }
122
48
 
123
49
  it 'returns true' do
124
- expect(BrDanfe::DanfeLib::Helper.address_is_too_big(pdf, address)).to be true
50
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.address_is_too_big(pdf, address)).to be true
125
51
  end
126
52
  end
127
53
 
@@ -129,7 +55,7 @@ describe BrDanfe::DanfeLib::Helper do
129
55
  let(:address) { 'Rua do governo do estado 1125 - Salas 1 e 2' }
130
56
 
131
57
  it 'returns false' do
132
- expect(BrDanfe::DanfeLib::Helper.address_is_too_big(pdf, address)).to be false
58
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.address_is_too_big(pdf, address)).to be false
133
59
  end
134
60
  end
135
61
  end
@@ -150,7 +76,7 @@ describe BrDanfe::DanfeLib::Helper do
150
76
  end
151
77
 
152
78
  it 'returns the address with the street, number and complement' do
153
- expect(BrDanfe::DanfeLib::Helper.generate_address(xml_street))
79
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.generate_address(xml_street))
154
80
  .to eq 'Rua do governo do estado 1125 - Em anexo ao super mercado maior do bairro'
155
81
  end
156
82
 
@@ -166,7 +92,7 @@ describe BrDanfe::DanfeLib::Helper do
166
92
  end
167
93
 
168
94
  it 'returns the address with the street and number' do
169
- expect(BrDanfe::DanfeLib::Helper.generate_address(xml_street))
95
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.generate_address(xml_street))
170
96
  .to eq 'Rua do governo do estado 1125'
171
97
  end
172
98
  end
@@ -183,7 +109,7 @@ describe BrDanfe::DanfeLib::Helper do
183
109
  end
184
110
 
185
111
  it 'returns the address with the street only' do
186
- expect(BrDanfe::DanfeLib::Helper.generate_address(xml_street))
112
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.generate_address(xml_street))
187
113
  .to eq 'Rua do governo do estado'
188
114
  end
189
115
  end
@@ -200,7 +126,7 @@ describe BrDanfe::DanfeLib::Helper do
200
126
  end
201
127
 
202
128
  it 'returns the address with the street and complement' do
203
- expect(BrDanfe::DanfeLib::Helper.generate_address(xml_street))
129
+ expect(BrDanfe::DanfeLib::NfeLib::Helper.generate_address(xml_street))
204
130
  .to eq 'Rua do governo do estado - Em anexo ao super mercado maior do bairro'
205
131
  end
206
132
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Icmstot do
3
+ describe BrDanfe::DanfeLib::NfeLib::Icmstot do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Infadic do
3
+ describe BrDanfe::DanfeLib::NfeLib::Infadic do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::InfadicVol do
3
+ describe BrDanfe::DanfeLib::NfeLib::InfadicVol do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
6
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
7
7
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
8
8
  subject { described_class.new(xml, pdf) }
9
9
 
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Issqn do
3
+ describe BrDanfe::DanfeLib::NfeLib::Issqn do
4
4
  let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::Phone do
3
+ describe BrDanfe::DanfeLib::NfeLib::Phone do
4
4
  describe '.format' do
5
5
  context 'when phone have 10 digits' do
6
6
  it 'returns a formated phone' do
7
7
  phone = '1234567890'
8
- expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq '(12) 3456-7890'
8
+ expect(BrDanfe::DanfeLib::NfeLib::Phone.format(phone)).to eq '(12) 3456-7890'
9
9
  end
10
10
  end
11
11
 
12
12
  context 'when phone have 11 digits' do
13
13
  it 'returns a formated phone' do
14
14
  phone = '12345678901'
15
- expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq '(12) 34567-8901'
15
+ expect(BrDanfe::DanfeLib::NfeLib::Phone.format(phone)).to eq '(12) 34567-8901'
16
16
  end
17
17
  end
18
18
  end