br_danfe 0.0.9 → 0.2.0

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.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -3
  3. data/br_danfe.gemspec +1 -0
  4. data/config/locales/pt-BR.yml +14 -0
  5. data/lib/br_danfe/cce.rb +28 -0
  6. data/lib/br_danfe/cce_lib/barcode.rb +24 -0
  7. data/lib/br_danfe/cce_lib/correction.rb +22 -0
  8. data/lib/br_danfe/cce_lib/document.rb +44 -0
  9. data/lib/br_danfe/cce_lib/footer.rb +15 -0
  10. data/lib/br_danfe/cce_lib/header.rb +15 -0
  11. data/lib/br_danfe/cce_lib/nfe_key.rb +23 -0
  12. data/lib/br_danfe/cce_lib/protocol.rb +23 -0
  13. data/lib/br_danfe/danfe.rb +16 -16
  14. data/lib/br_danfe/danfe_lib/cep.rb +9 -0
  15. data/lib/br_danfe/danfe_lib/consts.rb +6 -0
  16. data/lib/br_danfe/danfe_lib/cst.rb +30 -0
  17. data/lib/br_danfe/danfe_lib/dest.rb +86 -0
  18. data/lib/br_danfe/danfe_lib/det_body.rb +75 -0
  19. data/lib/br_danfe/danfe_lib/det_header.rb +40 -0
  20. data/lib/br_danfe/danfe_lib/document.rb +135 -0
  21. data/lib/br_danfe/danfe_lib/dup.rb +52 -0
  22. data/lib/br_danfe/danfe_lib/emit.rb +23 -0
  23. data/lib/br_danfe/danfe_lib/emit_header.rb +82 -0
  24. data/lib/br_danfe/danfe_lib/helper.rb +64 -0
  25. data/lib/br_danfe/danfe_lib/icmstot.rb +33 -0
  26. data/lib/br_danfe/danfe_lib/infadic.rb +80 -0
  27. data/lib/br_danfe/danfe_lib/issqn.rb +24 -0
  28. data/lib/br_danfe/danfe_lib/options.rb +24 -0
  29. data/lib/br_danfe/danfe_lib/phone.rb +13 -0
  30. data/lib/br_danfe/danfe_lib/plate.rb +9 -0
  31. data/lib/br_danfe/danfe_lib/ticket.rb +17 -0
  32. data/lib/br_danfe/danfe_lib/transp.rb +51 -0
  33. data/lib/br_danfe/danfe_lib/vol.rb +41 -0
  34. data/lib/br_danfe/danfe_lib/xml.rb +38 -0
  35. data/lib/br_danfe/danfe_lib/xprod.rb +48 -0
  36. data/lib/br_danfe/version.rb +1 -1
  37. data/lib/br_danfe.rb +1 -1
  38. data/spec/features/cce_spec.rb +28 -0
  39. data/spec/features/danfe_spec.rb +3 -3
  40. data/spec/fixtures/cce/lib/barcode#render.pdf +511 -0
  41. data/spec/fixtures/cce/lib/correction#render.pdf +100 -0
  42. data/spec/fixtures/cce/lib/document#box.pdf +55 -0
  43. data/spec/fixtures/cce/lib/document#box.with.block.pdf +72 -0
  44. data/spec/fixtures/cce/lib/document#text.align.pdf +70 -0
  45. data/spec/fixtures/cce/lib/document#text.pad.pdf +70 -0
  46. data/spec/fixtures/cce/lib/document#text.simple.pdf +70 -0
  47. data/spec/fixtures/cce/lib/document#text.size.pdf +70 -0
  48. data/spec/fixtures/cce/lib/document#text.style.pdf +70 -0
  49. data/spec/fixtures/cce/lib/footer#render.pdf +114 -0
  50. data/spec/fixtures/cce/lib/header#render.pdf +72 -0
  51. data/spec/fixtures/cce/lib/nfe_key#render.pdf +88 -0
  52. data/spec/fixtures/cce/lib/protocol#render.pdf +88 -0
  53. data/spec/fixtures/cce/v1.00/cce.fixture.pdf +659 -0
  54. data/spec/fixtures/cce/v1.00/cce.xml +1 -0
  55. data/spec/fixtures/{lib → nfe/lib}/dest#render-v2.00.pdf +0 -0
  56. data/spec/fixtures/{lib → nfe/lib}/dest#render-v3.10.pdf +0 -0
  57. data/spec/fixtures/{lib → nfe/lib}/dest#render-with_cnpj.pdf +0 -0
  58. data/spec/fixtures/{lib → nfe/lib}/dest#render-with_cpf.pdf +0 -0
  59. data/spec/fixtures/{lib → nfe/lib}/dest#render-with_ie.pdf +0 -0
  60. data/spec/fixtures/{lib → nfe/lib}/det_body#render-csosn.pdf +0 -0
  61. data/spec/fixtures/{lib → nfe/lib}/det_body#render-cst.pdf +0 -0
  62. data/spec/fixtures/{lib → nfe/lib}/det_body#render-fci.pdf +0 -0
  63. data/spec/fixtures/{lib → nfe/lib}/det_body#render-icms_st.pdf +0 -0
  64. data/spec/fixtures/{lib → nfe/lib}/det_header#render.pdf +0 -0
  65. data/spec/fixtures/{lib → nfe/lib}/document#lcnpj-blank.pdf +0 -0
  66. data/spec/fixtures/{lib → nfe/lib}/document#lcnpj-invalid.pdf +0 -0
  67. data/spec/fixtures/{lib → nfe/lib}/document#lcnpj-valid.pdf +0 -0
  68. data/spec/fixtures/{lib → nfe/lib}/document#lie-blank.pdf +0 -0
  69. data/spec/fixtures/{lib → nfe/lib}/document#lie-invalid.pdf +0 -0
  70. data/spec/fixtures/{lib → nfe/lib}/document#lie-valid.pdf +0 -0
  71. data/spec/fixtures/{lib → nfe/lib}/dup#render.pdf +0 -0
  72. data/spec/fixtures/{lib → nfe/lib}/emit#render.pdf +0 -0
  73. data/spec/fixtures/{lib → nfe/lib}/emit_header#render-with_logo.pdf +0 -0
  74. data/spec/fixtures/{lib → nfe/lib}/emit_header#render-without_logo.pdf +0 -0
  75. data/spec/fixtures/{lib → nfe/lib}/icmstot#render.pdf +0 -0
  76. data/spec/fixtures/{lib → nfe/lib}/infadic#render-extra_volume.pdf +0 -0
  77. data/spec/fixtures/{lib → nfe/lib}/infadic#render.pdf +0 -0
  78. data/spec/fixtures/{lib → nfe/lib}/issqn#render.pdf +0 -0
  79. data/spec/fixtures/{lib → nfe/lib}/ticket#render.pdf +0 -0
  80. data/spec/fixtures/{lib → nfe/lib}/transp#render-modfrete_0.pdf +0 -0
  81. data/spec/fixtures/{lib → nfe/lib}/transp#render-modfrete_1.pdf +0 -0
  82. data/spec/fixtures/{lib → nfe/lib}/transp#render-modfrete_2.pdf +0 -0
  83. data/spec/fixtures/{lib → nfe/lib}/transp#render-modfrete_9.pdf +0 -0
  84. data/spec/fixtures/{lib → nfe/lib}/transp#render.pdf +0 -0
  85. data/spec/fixtures/{lib → nfe/lib}/vol#render-blank-boxes.pdf +0 -0
  86. data/spec/fixtures/{lib → nfe/lib}/vol#render.pdf +0 -0
  87. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_simples_nacional.xml +0 -0
  88. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_simples_nacional.xml.fixture.pdf +0 -0
  89. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_extra_volumes.xml +0 -0
  90. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_extra_volumes.xml.fixture.pdf +0 -0
  91. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_fci.xml +0 -0
  92. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_fci.xml.fixture.pdf +0 -0
  93. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_logo.xml +0 -0
  94. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_ns.xml +0 -0
  95. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_with_ns.xml.fixture.pdf +0 -0
  96. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_without_ns.xml +0 -0
  97. data/spec/fixtures/{v2.00 → nfe/v2.00}/nfe_without_ns.xml.fixture.pdf +0 -0
  98. data/spec/fixtures/{v3.10 → nfe/v3.10}/nfe_simples_nacional.xml +0 -0
  99. data/spec/fixtures/{v3.10 → nfe/v3.10}/nfe_simples_nacional.xml.fixture.pdf +0 -0
  100. data/spec/lib/cce_lib/barcode_spec.rb +26 -0
  101. data/spec/lib/cce_lib/correction_spec.rb +26 -0
  102. data/spec/lib/cce_lib/document_spec.rb +115 -0
  103. data/spec/lib/cce_lib/footer_spec.rb +25 -0
  104. data/spec/lib/cce_lib/header_spec.rb +25 -0
  105. data/spec/lib/cce_lib/nfe_key_spec.rb +26 -0
  106. data/spec/lib/cce_lib/protocol_spec.rb +26 -0
  107. data/spec/lib/{cep_spec.rb → danfe_lib/cep_spec.rb} +2 -2
  108. data/spec/lib/{cst_spec.rb → danfe_lib/cst_spec.rb} +3 -3
  109. data/spec/lib/{dest_spec.rb → danfe_lib/dest_spec.rb} +4 -4
  110. data/spec/lib/{det_body_spec.rb → danfe_lib/det_body_spec.rb} +4 -4
  111. data/spec/lib/{det_header_spec.rb → danfe_lib/det_header_spec.rb} +4 -4
  112. data/spec/lib/{document_spec.rb → danfe_lib/document_spec.rb} +3 -3
  113. data/spec/lib/{dup_spec.rb → danfe_lib/dup_spec.rb} +4 -4
  114. data/spec/lib/{emit_header_spec.rb → danfe_lib/emit_header_spec.rb} +4 -4
  115. data/spec/lib/{emit_spec.rb → danfe_lib/emit_spec.rb} +4 -4
  116. data/spec/lib/{helper_spec.rb → danfe_lib/helper_spec.rb} +11 -11
  117. data/spec/lib/{icmstot_spec.rb → danfe_lib/icmstot_spec.rb} +4 -4
  118. data/spec/lib/{infadic_spec.rb → danfe_lib/infadic_spec.rb} +4 -4
  119. data/spec/lib/{issqn_spec.rb → danfe_lib/issqn_spec.rb} +4 -4
  120. data/spec/lib/{options_spec.rb → danfe_lib/options_spec.rb} +3 -3
  121. data/spec/lib/{phone_spec.rb → danfe_lib/phone_spec.rb} +3 -3
  122. data/spec/lib/{plate_spec.rb → danfe_lib/plate_spec.rb} +2 -2
  123. data/spec/lib/{ticket_spec.rb → danfe_lib/ticket_spec.rb} +4 -4
  124. data/spec/lib/{transp_spec.rb → danfe_lib/transp_spec.rb} +4 -4
  125. data/spec/lib/{vol_spec.rb → danfe_lib/vol_spec.rb} +4 -4
  126. data/spec/lib/{xml_spec.rb → danfe_lib/xml_spec.rb} +2 -2
  127. data/spec/lib/{xprod_spec.rb → danfe_lib/xprod_spec.rb} +5 -5
  128. metadata +242 -174
  129. data/lib/br_danfe/cep.rb +0 -7
  130. data/lib/br_danfe/consts.rb +0 -4
  131. data/lib/br_danfe/cst.rb +0 -28
  132. data/lib/br_danfe/dest.rb +0 -84
  133. data/lib/br_danfe/det_body.rb +0 -73
  134. data/lib/br_danfe/det_header.rb +0 -38
  135. data/lib/br_danfe/document.rb +0 -133
  136. data/lib/br_danfe/dup.rb +0 -50
  137. data/lib/br_danfe/emit.rb +0 -21
  138. data/lib/br_danfe/emit_header.rb +0 -80
  139. data/lib/br_danfe/helper.rb +0 -62
  140. data/lib/br_danfe/icmstot.rb +0 -31
  141. data/lib/br_danfe/infadic.rb +0 -78
  142. data/lib/br_danfe/issqn.rb +0 -22
  143. data/lib/br_danfe/options.rb +0 -22
  144. data/lib/br_danfe/phone.rb +0 -11
  145. data/lib/br_danfe/plate.rb +0 -7
  146. data/lib/br_danfe/ticket.rb +0 -15
  147. data/lib/br_danfe/transp.rb +0 -49
  148. data/lib/br_danfe/vol.rb +0 -39
  149. data/lib/br_danfe/xml.rb +0 -36
  150. data/lib/br_danfe/xprod.rb +0 -46
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Barcode do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+ let(:xml) { File.read("./spec/fixtures/cce/v1.00/cce.xml") }
9
+
10
+ subject { described_class.new(pdf, xml) }
11
+
12
+ describe "#render" do
13
+ before do
14
+ subject.render
15
+ File.delete(output_pdf) if File.exist?(output_pdf)
16
+ end
17
+
18
+ it "renders header to the pdf" do
19
+ expect(File.exist?(output_pdf)).to be_falsey
20
+
21
+ pdf.render_file output_pdf
22
+
23
+ expect("#{base_dir}barcode#render.pdf").to have_same_content_of file: output_pdf
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Correction do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+ let(:xml) { File.read("./spec/fixtures/cce/v1.00/cce.xml") }
9
+
10
+ subject { described_class.new(pdf, xml) }
11
+
12
+ describe "#render" do
13
+ before do
14
+ subject.render
15
+ File.delete(output_pdf) if File.exist?(output_pdf)
16
+ end
17
+
18
+ it "renders header to the pdf" do
19
+ expect(File.exist?(output_pdf)).to be_falsey
20
+
21
+ pdf.render_file output_pdf
22
+
23
+ expect("#{base_dir}correction#render.pdf").to have_same_content_of file: output_pdf
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,115 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Document do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ describe "#box" do
8
+ context "when a block isn't passed" do
9
+ before do
10
+ File.delete(output_pdf) if File.exist?(output_pdf)
11
+ subject.box(height: 50)
12
+ end
13
+
14
+ it "renders box with the page width" do
15
+ expect(File.exist?(output_pdf)).to be_falsey
16
+
17
+ subject.render_file output_pdf
18
+
19
+ expect("#{base_dir}document#box.pdf").to have_same_content_of file: output_pdf
20
+ end
21
+ end
22
+
23
+ context "when a block is passed" do
24
+ before do
25
+ File.delete(output_pdf) if File.exist?(output_pdf)
26
+ subject.box(height: 50) { subject.text "sample text" }
27
+ end
28
+
29
+ it "renders box with the block" do
30
+ expect(File.exist?(output_pdf)).to be_falsey
31
+
32
+ subject.render_file output_pdf
33
+
34
+ expect("#{base_dir}document#box.with.block.pdf").to have_same_content_of file: output_pdf
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#text" do
40
+ context "when is a simple text" do
41
+ before do
42
+ File.delete(output_pdf) if File.exist?(output_pdf)
43
+ subject.text "simple text"
44
+ end
45
+
46
+ it "renders the text" do
47
+ expect(File.exist?(output_pdf)).to be_falsey
48
+
49
+ subject.render_file output_pdf
50
+
51
+ expect("#{base_dir}document#text.simple.pdf").to have_same_content_of file: output_pdf
52
+ end
53
+ end
54
+
55
+ context "when is a text with style" do
56
+ before do
57
+ File.delete(output_pdf) if File.exist?(output_pdf)
58
+ subject.text "bold text", style: :bold
59
+ end
60
+
61
+ it "renders the text" do
62
+ expect(File.exist?(output_pdf)).to be_falsey
63
+
64
+ subject.render_file output_pdf
65
+
66
+ expect("#{base_dir}document#text.style.pdf").to have_same_content_of file: output_pdf
67
+ end
68
+ end
69
+
70
+ context "when is a text with size" do
71
+ before do
72
+ File.delete(output_pdf) if File.exist?(output_pdf)
73
+ subject.text "big text", size: 25
74
+ end
75
+
76
+ it "renders the text" do
77
+ expect(File.exist?(output_pdf)).to be_falsey
78
+
79
+ subject.render_file output_pdf
80
+
81
+ expect("#{base_dir}document#text.size.pdf").to have_same_content_of file: output_pdf
82
+ end
83
+ end
84
+
85
+ context "when is a text with pad" do
86
+ before do
87
+ File.delete(output_pdf) if File.exist?(output_pdf)
88
+ subject.text "text with pad", pad: 50
89
+ end
90
+
91
+ it "renders the text" do
92
+ expect(File.exist?(output_pdf)).to be_falsey
93
+
94
+ subject.render_file output_pdf
95
+
96
+ expect("#{base_dir}document#text.pad.pdf").to have_same_content_of file: output_pdf
97
+ end
98
+ end
99
+
100
+ context "when is a text with align" do
101
+ before do
102
+ File.delete(output_pdf) if File.exist?(output_pdf)
103
+ subject.text "text in center", align: :center
104
+ end
105
+
106
+ it "renders the text" do
107
+ expect(File.exist?(output_pdf)).to be_falsey
108
+
109
+ subject.render_file output_pdf
110
+
111
+ expect("#{base_dir}document#text.align.pdf").to have_same_content_of file: output_pdf
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Footer do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+
9
+ subject { described_class.new(pdf) }
10
+
11
+ describe "#render" do
12
+ before do
13
+ subject.render
14
+ File.delete(output_pdf) if File.exist?(output_pdf)
15
+ end
16
+
17
+ it "renders header to the pdf" do
18
+ expect(File.exist?(output_pdf)).to be_falsey
19
+
20
+ pdf.render_file output_pdf
21
+
22
+ expect("#{base_dir}footer#render.pdf").to have_same_content_of file: output_pdf
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Header do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+
9
+ subject { described_class.new(pdf) }
10
+
11
+ describe "#render" do
12
+ before do
13
+ subject.render
14
+ File.delete(output_pdf) if File.exist?(output_pdf)
15
+ end
16
+
17
+ it "renders header to the pdf" do
18
+ expect(File.exist?(output_pdf)).to be_falsey
19
+
20
+ pdf.render_file output_pdf
21
+
22
+ expect("#{base_dir}header#render.pdf").to have_same_content_of file: output_pdf
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::NfeKey do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+ let(:xml) { File.read("./spec/fixtures/cce/v1.00/cce.xml") }
9
+
10
+ subject { described_class.new(pdf, xml) }
11
+
12
+ describe "#render" do
13
+ before do
14
+ subject.render
15
+ File.delete(output_pdf) if File.exist?(output_pdf)
16
+ end
17
+
18
+ it "renders header to the pdf" do
19
+ expect(File.exist?(output_pdf)).to be_falsey
20
+
21
+ pdf.render_file output_pdf
22
+
23
+ expect("#{base_dir}nfe_key#render.pdf").to have_same_content_of file: output_pdf
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe BrDanfe::CceLib::Protocol do
4
+ let(:base_dir) { "./spec/fixtures/cce/lib/"}
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+
7
+ let(:pdf) { BrDanfe::CceLib::Document.new }
8
+ let(:xml) { File.read("./spec/fixtures/cce/v1.00/cce.xml") }
9
+
10
+ subject { described_class.new(pdf, xml) }
11
+
12
+ describe "#render" do
13
+ before do
14
+ subject.render
15
+ File.delete(output_pdf) if File.exist?(output_pdf)
16
+ end
17
+
18
+ it "renders header to the pdf" do
19
+ expect(File.exist?(output_pdf)).to be_falsey
20
+
21
+ pdf.render_file output_pdf
22
+
23
+ expect("#{base_dir}protocol#render.pdf").to have_same_content_of file: output_pdf
24
+ end
25
+ end
26
+ end
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Cep do
3
+ describe BrDanfe::DanfeLib::Cep do
4
4
  describe ".format" do
5
5
  it "returns a formated CEP" do
6
6
  cep = "12345678"
7
- expect(BrDanfe::Cep.format(cep)).to eq "12.345-678"
7
+ expect(BrDanfe::DanfeLib::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::Cst do
3
+ describe BrDanfe::DanfeLib::Cst do
4
4
  let(:xml_cst) do
5
5
  xml = <<-eos
6
6
  <imposto>
@@ -38,13 +38,13 @@ describe BrDanfe::Cst do
38
38
  describe ".to_danfe" do
39
39
  context "when CST" do
40
40
  it "returns origin + CST" do
41
- expect(BrDanfe::Cst.to_danfe(xml_cst)).to eq "500"
41
+ expect(BrDanfe::DanfeLib::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::Cst.to_danfe(xml_csosn)).to eq "4102"
47
+ expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_csosn)).to eq "4102"
48
48
  end
49
49
  end
50
50
  end
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Dest do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Dest do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::DetBody do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::DetBody do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::DetHeader do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::DetHeader do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf) }
11
11
 
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Document do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Document do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
8
8
 
9
9
  describe "#lie" do
10
10
  before do
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Dup do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Dup do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::EmitHeader do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::EmitHeader do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  describe "#render" do
11
11
  let(:xml_as_string) do
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Emit do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Emit do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,15 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Helper do
3
+ describe BrDanfe::DanfeLib::Helper do
4
4
  describe ".format_datetime" do
5
5
  it "returns a formated string" do
6
6
  string = "2013-10-18T13:54:04"
7
- expect(BrDanfe::Helper.format_datetime(string)).to eq "18/10/2013 13:54:04"
7
+ expect(BrDanfe::DanfeLib::Helper.format_datetime(string)).to eq "18/10/2013 13:54:04"
8
8
  end
9
9
 
10
10
  describe "when the source is blank" do
11
11
  it "is empty" do
12
- expect(BrDanfe::Helper.format_datetime("")).to eq ""
12
+ expect(BrDanfe::DanfeLib::Helper.format_datetime("")).to eq ""
13
13
  end
14
14
  end
15
15
  end
@@ -17,12 +17,12 @@ describe BrDanfe::Helper do
17
17
  describe ".format_date" do
18
18
  it "returns a formated string" do
19
19
  string = "2013-10-18T13:54:04"
20
- expect(BrDanfe::Helper.format_date(string)).to eq "18/10/2013"
20
+ expect(BrDanfe::DanfeLib::Helper.format_date(string)).to eq "18/10/2013"
21
21
  end
22
22
 
23
23
  describe "when the source is blank" do
24
24
  it "is empty" do
25
- expect(BrDanfe::Helper.format_date("")).to eq ""
25
+ expect(BrDanfe::DanfeLib::Helper.format_date("")).to eq ""
26
26
  end
27
27
  end
28
28
  end
@@ -32,7 +32,7 @@ describe BrDanfe::Helper do
32
32
  let(:param) { "2013-10-18T16:54:04-03:00" }
33
33
 
34
34
  it "is a formated time string in localtime" do
35
- expect(BrDanfe::Helper.format_time(param)).to eq "16:54:04"
35
+ expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq "16:54:04"
36
36
  end
37
37
  end
38
38
 
@@ -40,7 +40,7 @@ describe BrDanfe::Helper do
40
40
  let(:param) { "14:23:02" }
41
41
 
42
42
  it "is a formated time string" do
43
- expect(BrDanfe::Helper.format_time(param)).to eq "14:23:02"
43
+ expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq "14:23:02"
44
44
  end
45
45
  end
46
46
 
@@ -48,7 +48,7 @@ describe BrDanfe::Helper do
48
48
  let(:param) { "" }
49
49
 
50
50
  it "is empty" do
51
- expect(BrDanfe::Helper.format_time(param)).to eq ""
51
+ expect(BrDanfe::DanfeLib::Helper.format_time(param)).to eq ""
52
52
  end
53
53
  end
54
54
  end
@@ -110,19 +110,19 @@ describe BrDanfe::Helper do
110
110
 
111
111
  context "when XML is unauthorized" do
112
112
  it "returns true" do
113
- expect(BrDanfe::Helper.has_no_fiscal_value?(xml_unauthorized)).to eq true
113
+ expect(BrDanfe::DanfeLib::Helper.has_no_fiscal_value?(xml_unauthorized)).to eq true
114
114
  end
115
115
  end
116
116
 
117
117
  context "when XML is in homologation environment" do
118
118
  it "returns true" do
119
- expect(BrDanfe::Helper.has_no_fiscal_value?(xml_homologation)).to eq true
119
+ expect(BrDanfe::DanfeLib::Helper.has_no_fiscal_value?(xml_homologation)).to eq true
120
120
  end
121
121
  end
122
122
 
123
123
  context "when XML is authorized" do
124
124
  it "returns false" do
125
- expect(BrDanfe::Helper.has_no_fiscal_value?(xml_authorized)).to eq false
125
+ expect(BrDanfe::DanfeLib::Helper.has_no_fiscal_value?(xml_authorized)).to eq false
126
126
  end
127
127
  end
128
128
  end
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Icmstot do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Icmstot do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Infadic do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Infadic do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Issqn do
4
- let(:base_dir) { "./spec/fixtures/lib/"}
3
+ describe BrDanfe::DanfeLib::Issqn do
4
+ let(:base_dir) { "./spec/fixtures/nfe/lib/"}
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
- let(:pdf) { BrDanfe::Document.new }
8
- let(:xml) { BrDanfe::XML.new(xml_as_string) }
7
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
@@ -1,13 +1,13 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Options do
3
+ describe BrDanfe::DanfeLib::Options do
4
4
  it "returns the default config set in the code" do
5
- options = BrDanfe::Options.new
5
+ options = BrDanfe::DanfeLib::Options.new
6
6
  expect(options.logo_path).to eq("")
7
7
  end
8
8
 
9
9
  it "returns the config set in params" do
10
- options = BrDanfe::Options.new({"logo_path" => "/fake/path/file.png"})
10
+ options = BrDanfe::DanfeLib::Options.new({"logo_path" => "/fake/path/file.png"})
11
11
  expect(options.logo_path).to eq("/fake/path/file.png")
12
12
  end
13
13
  end
@@ -1,18 +1,18 @@
1
1
  require "spec_helper"
2
2
 
3
- describe BrDanfe::Phone do
3
+ describe BrDanfe::DanfeLib::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::Phone.format(phone)).to eq "(12) 3456-7890"
8
+ expect(BrDanfe::DanfeLib::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::Phone.format(phone)).to eq "(12) 34567-8901"
15
+ expect(BrDanfe::DanfeLib::Phone.format(phone)).to eq "(12) 34567-8901"
16
16
  end
17
17
  end
18
18
  end