forked from sandrods/odf-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsections_spec.rb
51 lines (36 loc) · 1.26 KB
/
sections_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
RSpec.describe "Sections" do
before(:context) do
@itens = Item.get_list(3)
report = ODFReport::Report.new("spec/templates/specs.odt") do |r|
r.add_section('SECTION_01', @itens) do |t|
t.add_field(:s01_field_01, :id)
t.add_field(:s01_field_02, :name)
end
r.add_section('SECTION_02', []) do |t|
t.add_field(:s02_field_01, :id)
t.add_field(:s02_field_02, :name)
end
r.add_section('SECTION_03', nil) do |t|
t.add_field(:s03_field_01, :id)
t.add_field(:s03_field_02, :name)
end
end
report.generate("spec/result/specs.odt")
@data = Inspector.new("spec/result/specs.odt")
end
it "should render section with collection" do
@itens.each_with_index do |item, idx|
section = @data.xml.at_xpath(".//text:section[#{idx+1}]").to_s
expect(section).to match(item.id.to_s)
expect(section).to match(item.name)
end
end
it "should remove section with empty collection" do
section = @data.xml.at_xpath("//text:section[@text:name='SECTION_02']")
expect(section).to be_nil
end
it "should remove section with nil collection" do
section = @data.xml.at_xpath("//text:section[@text:name='SECTION_03']")
expect(section).to be_nil
end
end