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,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Barcode do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
|
-
let(:xml) { File.read(
|
8
|
+
let(:xml) { File.read('./spec/fixtures/cce/v1.00/cce.xml') }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
before do
|
14
14
|
subject.render
|
15
15
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'renders header to the pdf' do
|
19
19
|
expect(File.exist?(output_pdf)).to be_falsey
|
20
20
|
|
21
21
|
pdf.render_file output_pdf
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Correction do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
|
-
let(:xml) { File.read(
|
8
|
+
let(:xml) { File.read('./spec/fixtures/cce/v1.00/cce.xml') }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
before do
|
14
14
|
subject.render
|
15
15
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'renders header to the pdf' do
|
19
19
|
expect(File.exist?(output_pdf)).to be_falsey
|
20
20
|
|
21
21
|
pdf.render_file output_pdf
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Document do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe '#box' do
|
8
8
|
context "when a block isn't passed" do
|
9
9
|
before do
|
10
10
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
11
11
|
subject.box(height: 50)
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'renders box with the page width' do
|
15
15
|
expect(File.exist?(output_pdf)).to be_falsey
|
16
16
|
|
17
17
|
subject.render_file output_pdf
|
@@ -20,13 +20,13 @@ describe BrDanfe::CceLib::Document do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context 'when a block is passed' do
|
24
24
|
before do
|
25
25
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
26
|
-
subject.box(height: 50) { subject.text
|
26
|
+
subject.box(height: 50) { subject.text 'sample text' }
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'renders box with the block' do
|
30
30
|
expect(File.exist?(output_pdf)).to be_falsey
|
31
31
|
|
32
32
|
subject.render_file output_pdf
|
@@ -36,14 +36,14 @@ describe BrDanfe::CceLib::Document do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
context
|
39
|
+
describe '#text' do
|
40
|
+
context 'when is a simple text' do
|
41
41
|
before do
|
42
42
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
43
|
-
subject.text
|
43
|
+
subject.text 'simple text'
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'renders the text' do
|
47
47
|
expect(File.exist?(output_pdf)).to be_falsey
|
48
48
|
|
49
49
|
subject.render_file output_pdf
|
@@ -52,13 +52,13 @@ describe BrDanfe::CceLib::Document do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
context
|
55
|
+
context 'when is a text with style' do
|
56
56
|
before do
|
57
57
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
58
|
-
subject.text
|
58
|
+
subject.text 'bold text', style: :bold
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it 'renders the text' do
|
62
62
|
expect(File.exist?(output_pdf)).to be_falsey
|
63
63
|
|
64
64
|
subject.render_file output_pdf
|
@@ -67,13 +67,13 @@ describe BrDanfe::CceLib::Document do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
context
|
70
|
+
context 'when is a text with size' do
|
71
71
|
before do
|
72
72
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
73
|
-
subject.text
|
73
|
+
subject.text 'big text', size: 25
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'renders the text' do
|
77
77
|
expect(File.exist?(output_pdf)).to be_falsey
|
78
78
|
|
79
79
|
subject.render_file output_pdf
|
@@ -82,13 +82,13 @@ describe BrDanfe::CceLib::Document do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
context
|
85
|
+
context 'when is a text with pad' do
|
86
86
|
before do
|
87
87
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
88
|
-
subject.text
|
88
|
+
subject.text 'text with pad', pad: 50
|
89
89
|
end
|
90
90
|
|
91
|
-
it
|
91
|
+
it 'renders the text' do
|
92
92
|
expect(File.exist?(output_pdf)).to be_falsey
|
93
93
|
|
94
94
|
subject.render_file output_pdf
|
@@ -97,13 +97,13 @@ describe BrDanfe::CceLib::Document do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
context
|
100
|
+
context 'when is a text with align' do
|
101
101
|
before do
|
102
102
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
103
|
-
subject.text
|
103
|
+
subject.text 'text in center', align: :center
|
104
104
|
end
|
105
105
|
|
106
|
-
it
|
106
|
+
it 'renders the text' do
|
107
107
|
expect(File.exist?(output_pdf)).to be_falsey
|
108
108
|
|
109
109
|
subject.render_file output_pdf
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Footer do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
8
|
|
9
9
|
subject { described_class.new(pdf) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe '#render' do
|
12
12
|
before do
|
13
13
|
subject.render
|
14
14
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'renders header to the pdf' do
|
18
18
|
expect(File.exist?(output_pdf)).to be_falsey
|
19
19
|
|
20
20
|
pdf.render_file output_pdf
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Header do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
8
|
|
9
9
|
subject { described_class.new(pdf) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe '#render' do
|
12
12
|
before do
|
13
13
|
subject.render
|
14
14
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'renders header to the pdf' do
|
18
18
|
expect(File.exist?(output_pdf)).to be_falsey
|
19
19
|
|
20
20
|
pdf.render_file output_pdf
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::NfeKey do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
|
-
let(:xml) { File.read(
|
8
|
+
let(:xml) { File.read('./spec/fixtures/cce/v1.00/cce.xml') }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
before do
|
14
14
|
subject.render
|
15
15
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'renders header to the pdf' do
|
19
19
|
expect(File.exist?(output_pdf)).to be_falsey
|
20
20
|
|
21
21
|
pdf.render_file output_pdf
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::CceLib::Protocol do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::CceLib::Document.new }
|
8
|
-
let(:xml) { File.read(
|
8
|
+
let(:xml) { File.read('./spec/fixtures/cce/v1.00/cce.xml') }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#render' do
|
13
13
|
before do
|
14
14
|
subject.render
|
15
15
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'renders header to the pdf' do
|
19
19
|
expect(File.exist?(output_pdf)).to be_falsey
|
20
20
|
|
21
21
|
pdf.render_file output_pdf
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Cep do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
cep =
|
7
|
-
expect(BrDanfe::DanfeLib::Cep.format(cep)).to eq
|
4
|
+
describe '.format' do
|
5
|
+
it 'returns a formated CEP' do
|
6
|
+
cep = '12345678'
|
7
|
+
expect(BrDanfe::DanfeLib::Cep.format(cep)).to eq '12.345-678'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Cst do
|
4
4
|
let(:xml_cst) do
|
@@ -35,16 +35,16 @@ describe BrDanfe::DanfeLib::Cst do
|
|
35
35
|
Nokogiri::XML(xml)
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
39
|
-
context
|
40
|
-
it
|
41
|
-
expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_cst)).to eq
|
38
|
+
describe '.to_danfe' do
|
39
|
+
context 'when CST' do
|
40
|
+
it 'returns origin + CST' do
|
41
|
+
expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_cst)).to eq '500'
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context
|
46
|
-
it
|
47
|
-
expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_csosn)).to eq
|
45
|
+
context 'when CSOSN' do
|
46
|
+
it 'returns origin + CSOSN' do
|
47
|
+
expect(BrDanfe::DanfeLib::Cst.to_danfe(xml_csosn)).to eq '4102'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Dest do
|
4
|
-
let(:path_of_expected_pdf) {
|
4
|
+
let(:path_of_expected_pdf) { './spec/fixtures/nfe/lib/output.pdf' }
|
5
5
|
|
6
6
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
7
7
|
let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
|
8
8
|
|
9
9
|
subject { described_class.new(pdf, xml) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe '#render' do
|
12
12
|
before do
|
13
13
|
File.delete(path_of_expected_pdf) if File.exist?(path_of_expected_pdf)
|
14
14
|
subject.render
|
@@ -47,12 +47,12 @@ describe BrDanfe::DanfeLib::Dest do
|
|
47
47
|
eos
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it 'renders xml to the pdf' do
|
51
51
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
52
52
|
|
53
53
|
pdf.render_file path_of_expected_pdf
|
54
54
|
|
55
|
-
expect(
|
55
|
+
expect('./spec/fixtures/nfe/lib/dest#render-v2.00.pdf').to have_same_content_of file: path_of_expected_pdf
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -88,12 +88,12 @@ describe BrDanfe::DanfeLib::Dest do
|
|
88
88
|
eos
|
89
89
|
end
|
90
90
|
|
91
|
-
it
|
91
|
+
it 'renders xml to the pdf' do
|
92
92
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
93
93
|
|
94
94
|
pdf.render_file path_of_expected_pdf
|
95
95
|
|
96
|
-
expect(
|
96
|
+
expect('./spec/fixtures/nfe/lib/dest#render-v3.10.pdf').to have_same_content_of file: path_of_expected_pdf
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -129,16 +129,16 @@ describe BrDanfe::DanfeLib::Dest do
|
|
129
129
|
eos
|
130
130
|
end
|
131
131
|
|
132
|
-
it
|
132
|
+
it 'renders xml to the pdf' do
|
133
133
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
134
134
|
|
135
135
|
pdf.render_file path_of_expected_pdf
|
136
136
|
|
137
|
-
expect(
|
137
|
+
expect('./spec/fixtures/nfe/lib/dest#render-v4.00.pdf').to have_same_content_of file: path_of_expected_pdf
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
context
|
141
|
+
context 'when recipient has CNPJ' do
|
142
142
|
let(:xml_as_string) do
|
143
143
|
<<-eos
|
144
144
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -151,16 +151,16 @@ describe BrDanfe::DanfeLib::Dest do
|
|
151
151
|
eos
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
154
|
+
it 'renders xml to the pdf' do
|
155
155
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
156
156
|
|
157
157
|
pdf.render_file path_of_expected_pdf
|
158
158
|
|
159
|
-
expect(
|
159
|
+
expect('./spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf').to have_same_content_of file: path_of_expected_pdf
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
context
|
163
|
+
context 'when recipient has CPF' do
|
164
164
|
let(:xml_as_string) do
|
165
165
|
<<-eos
|
166
166
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -173,16 +173,16 @@ describe BrDanfe::DanfeLib::Dest do
|
|
173
173
|
eos
|
174
174
|
end
|
175
175
|
|
176
|
-
it
|
176
|
+
it 'renders xml to the pdf' do
|
177
177
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
178
178
|
|
179
179
|
pdf.render_file path_of_expected_pdf
|
180
180
|
|
181
|
-
expect(
|
181
|
+
expect('./spec/fixtures/nfe/lib/dest#render-with_cpf.pdf').to have_same_content_of file: path_of_expected_pdf
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
|
-
context
|
185
|
+
context 'when recipient has IE' do
|
186
186
|
let(:xml_as_string) do
|
187
187
|
<<-eos
|
188
188
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -198,12 +198,12 @@ describe BrDanfe::DanfeLib::Dest do
|
|
198
198
|
eos
|
199
199
|
end
|
200
200
|
|
201
|
-
it
|
201
|
+
it 'renders xml to the pdf' do
|
202
202
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
203
203
|
|
204
204
|
pdf.render_file path_of_expected_pdf
|
205
205
|
|
206
|
-
expect(
|
206
|
+
expect('./spec/fixtures/nfe/lib/dest#render-with_ie.pdf').to have_same_content_of file: path_of_expected_pdf
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -238,17 +238,17 @@ describe BrDanfe::DanfeLib::Dest do
|
|
238
238
|
eos
|
239
239
|
end
|
240
240
|
|
241
|
-
it
|
241
|
+
it 'renders xml to the pdf' do
|
242
242
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
243
243
|
|
244
244
|
pdf.render_file path_of_expected_pdf
|
245
245
|
|
246
|
-
expect(
|
246
|
+
expect('./spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf')
|
247
247
|
.to have_same_content_of file: path_of_expected_pdf
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
-
context
|
251
|
+
context 'when recipient address (xLgr + nro + xCpl) has more than 63 characters' do
|
252
252
|
let(:xml_as_string) do
|
253
253
|
<<-eos
|
254
254
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -280,12 +280,12 @@ describe BrDanfe::DanfeLib::Dest do
|
|
280
280
|
eos
|
281
281
|
end
|
282
282
|
|
283
|
-
it
|
283
|
+
it 'renders xml to pdf discarding the address of after 63 characters' do
|
284
284
|
expect(File.exist?(path_of_expected_pdf)).to eql false
|
285
285
|
|
286
286
|
pdf.render_file path_of_expected_pdf
|
287
287
|
|
288
|
-
expect(
|
288
|
+
expect('./spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf')
|
289
289
|
.to have_same_content_of file: path_of_expected_pdf
|
290
290
|
end
|
291
291
|
end
|