caracal_the_curve 1.4.1 → 1.4.2

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/caracal.gemspec +2 -2
  3. data/lib/caracal/core/fields.rb +34 -0
  4. data/lib/caracal/core/footer.rb +33 -0
  5. data/lib/caracal/core/header.rb +32 -0
  6. data/lib/caracal/core/models/field_model.rb +124 -0
  7. data/lib/caracal/core/models/footer_model.rb +42 -0
  8. data/lib/caracal/core/models/header_model.rb +42 -0
  9. data/lib/caracal/core/models/page_flip_model.rb +41 -0
  10. data/lib/caracal/core/models/paragraph_model.rb +15 -0
  11. data/lib/caracal/core/models/relationship_model.rb +1 -0
  12. data/lib/caracal/core/models/style_model.rb +6 -2
  13. data/lib/caracal/core/page_flips.rb +34 -0
  14. data/lib/caracal/core/relationships.rb +1 -0
  15. data/lib/caracal/core/styles.rb +7 -7
  16. data/lib/caracal/document.rb +24 -0
  17. data/lib/caracal/renderers/content_types_renderer.rb +1 -0
  18. data/lib/caracal/renderers/document_renderer.rb +52 -4
  19. data/lib/caracal/renderers/footer_renderer.rb +42 -29
  20. data/lib/caracal/renderers/header_renderer.rb +61 -0
  21. data/lib/caracal/renderers/settings_renderer.rb +2 -1
  22. data/lib/caracal/renderers/styles_renderer.rb +2 -0
  23. data/lib/caracal/version.rb +1 -1
  24. data/lib/caracal.rb +24 -0
  25. data/spec/lib/caracal/core/fields_spec.rb +25 -0
  26. data/spec/lib/caracal/core/footer_spec.rb +31 -0
  27. data/spec/lib/caracal/core/header_spec.rb +31 -0
  28. data/spec/lib/caracal/core/models/footer_model_spec.rb +40 -0
  29. data/spec/lib/caracal/core/models/header_model_spec.rb +40 -0
  30. data/spec/lib/caracal/core/models/page_flip_model_spec.rb +34 -0
  31. data/spec/lib/caracal/core/models/paragraph_model_spec.rb +18 -1
  32. data/spec/lib/caracal/core/models/style_model_spec.rb +8 -1
  33. data/spec/lib/caracal/core/page_flip_spec.rb +27 -0
  34. data/spec/lib/caracal/core/relationships_spec.rb +2 -2
  35. metadata +30 -3
@@ -31,10 +31,11 @@ module Caracal
31
31
  #============= PAGE SETTINGS ==============================
32
32
 
33
33
  xml['w'].sectPr do
34
- if document.page_number_show
35
- if rel = document.find_relationship('footer1.xml')
36
- xml['w'].footerReference({ 'r:id' => rel.formatted_id, 'w:type' => 'default' })
37
- end
34
+ if rel = document.find_relationship('footer1.xml')
35
+ xml['w'].footerReference({ 'r:id' => rel.formatted_id, 'w:type' => 'default' })
36
+ end
37
+ if rel = document.find_relationship('header1.xml')
38
+ xml['w'].headerReference({ 'r:id' => rel.formatted_id, 'w:type' => 'default' })
38
39
  end
39
40
  xml['w'].pgSz page_size_options
40
41
  xml['w'].pgMar page_margin_options
@@ -219,6 +220,26 @@ module Caracal
219
220
  end
220
221
  end
221
222
 
223
+ def render_field(xml, model)
224
+ xml['w'].r do
225
+ xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
226
+ end
227
+ xml['w'].r do
228
+ xml['w'].rPr do
229
+ render_run_attributes(xml, model, false)
230
+ end
231
+ xml['w'].instrText({ 'xml:space' => 'preserve' }) do
232
+ xml.text " #{model.formatted_type} "
233
+ end
234
+ end
235
+ xml['w'].r do
236
+ xml['w'].fldChar({ 'w:fldCharType' => 'separate' })
237
+ end
238
+ xml['w'].r do
239
+ xml['w'].fldChar({ 'w:fldCharType' => 'end' })
240
+ end
241
+ end
242
+
222
243
  def render_list(xml, model)
223
244
  if model.list_level == 0
224
245
  document.toplevel_lists << model
@@ -253,6 +274,33 @@ module Caracal
253
274
  end
254
275
  end
255
276
 
277
+ def render_pageflip(xml, model)
278
+ xml['w'].p paragraph_options do
279
+ xml['w'].pPr do
280
+ xml['w'].sectPr do
281
+ xml['w'].pgSz({
282
+ 'w:w' => document.page_width,
283
+ 'w:h' => document.page_height
284
+ })
285
+ end
286
+ end
287
+ end
288
+ model.contents.each do |model|
289
+ method = render_method_for_model(model)
290
+ send(method, xml, model)
291
+ end
292
+ xml['w'].p paragraph_options do
293
+ xml['w'].pPr do
294
+ xml['w'].sectPr do
295
+ xml['w'].pgSz({
296
+ 'w:w' => document.page_height,
297
+ 'w:h' => document.page_width
298
+ })
299
+ end
300
+ end
301
+ end
302
+ end
303
+
256
304
  def render_pagebreak(xml, model)
257
305
  if model.page_break_wrap
258
306
  xml['w'].p paragraph_options do
@@ -5,52 +5,65 @@ require 'caracal/renderers/xml_renderer'
5
5
 
6
6
  module Caracal
7
7
  module Renderers
8
- class FooterRenderer < XmlRenderer
8
+ class FooterRenderer < DocumentRenderer
9
9
 
10
10
  #-------------------------------------------------------------
11
11
  # Public Methods
12
12
  #-------------------------------------------------------------
13
13
 
14
- # This method produces the xml required for the `word/settings.xml`
14
+ # This method produces the xml required for the `word/footer1.xml`
15
15
  # sub-document.
16
16
  #
17
17
  def to_xml
18
18
  builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
19
- xml['w'].ftr root_options do
20
- xml['w'].p paragraph_options do
21
- xml['w'].pPr do
22
- xml['w'].contextualSpacing({ 'w:val' => '0' })
23
- xml['w'].jc({ 'w:val' => "#{ document.page_number_align }" })
24
- end
25
- unless document.page_number_label.nil?
19
+ if document.page_number_show
20
+ xml['w'].ftr root_options do
21
+ xml['w'].p paragraph_options do
22
+ xml['w'].pPr do
23
+ xml['w'].contextualSpacing({ 'w:val' => '0' })
24
+ xml['w'].jc({ 'w:val' => "#{ document.page_number_align }" })
25
+ end
26
+ unless document.page_number_label.nil?
27
+ xml['w'].r run_options do
28
+ xml['w'].rPr do
29
+ xml['w'].rStyle({ 'w:val' => 'PageNumber' })
30
+ unless document.page_number_label_size.nil?
31
+ xml['w'].sz({ 'w:val' => document.page_number_label_size })
32
+ end
33
+ end
34
+ xml['w'].t({ 'xml:space' => 'preserve' }) do
35
+ xml.text "#{ document.page_number_label } "
36
+ end
37
+ end
38
+ end
26
39
  xml['w'].r run_options do
27
40
  xml['w'].rPr do
28
- xml['w'].rStyle({ 'w:val' => 'PageNumber' })
29
- unless document.page_number_label_size.nil?
30
- xml['w'].sz({ 'w:val' => document.page_number_label_size })
41
+ unless document.page_number_number_size.nil?
42
+ xml['w'].sz({ 'w:val' => document.page_number_number_size })
43
+ xml['w'].szCs({ 'w:val' => document.page_number_number_size })
31
44
  end
32
45
  end
33
- xml['w'].t({ 'xml:space' => 'preserve' }) do
34
- xml.text "#{ document.page_number_label } "
46
+ xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
47
+ xml['w'].instrText({ 'xml:space' => 'preserve' }) do
48
+ xml.text 'PAGE'
35
49
  end
50
+ xml['w'].fldChar({ 'w:fldCharType' => 'end' })
36
51
  end
37
- end
38
- xml['w'].r run_options do
39
- xml['w'].rPr do
40
- unless document.page_number_number_size.nil?
41
- xml['w'].sz({ 'w:val' => document.page_number_number_size })
42
- xml['w'].szCs({ 'w:val' => document.page_number_number_size })
52
+ xml['w'].r run_options do
53
+ xml['w'].rPr do
54
+ xml['w'].rtl({ 'w:val' => '0' })
43
55
  end
44
56
  end
45
- xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
46
- xml['w'].instrText({ 'xml:space' => 'preserve' }) do
47
- xml.text 'PAGE'
48
- end
49
- xml['w'].fldChar({ 'w:fldCharType' => 'end' })
50
57
  end
51
- xml['w'].r run_options do
52
- xml['w'].rPr do
53
- xml['w'].rtl({ 'w:val' => '0' })
58
+ end
59
+ else
60
+ xml['w'].ftr root_options do
61
+
62
+ #============= CONTENTS ===================================
63
+ if document.footer_content&.valid?
64
+ document.footer_content.contents.each do |model|
65
+ method = render_method_for_model(model)
66
+ send(method, xml, model)
54
67
  end
55
68
  end
56
69
  end
@@ -87,4 +100,4 @@ module Caracal
87
100
 
88
101
  end
89
102
  end
90
- end
103
+ end
@@ -0,0 +1,61 @@
1
+ require 'nokogiri'
2
+
3
+ require 'caracal/renderers/xml_renderer'
4
+
5
+
6
+ module Caracal
7
+ module Renderers
8
+ class HeaderRenderer < DocumentRenderer
9
+
10
+ #-------------------------------------------------------------
11
+ # Public Methods
12
+ #-------------------------------------------------------------
13
+
14
+ # This method produces the xml required for the `word/header1.xml`
15
+ # sub-document.
16
+ #
17
+ def to_xml
18
+ builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
19
+ xml['w'].hdr root_options do
20
+
21
+ #============= CONTENTS ===================================
22
+ if document.header_content&.valid?
23
+ document.header_content.contents.each do |model|
24
+ method = render_method_for_model(model)
25
+ send(method, xml, model)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ builder.to_xml(save_options)
31
+ end
32
+
33
+
34
+ #-------------------------------------------------------------
35
+ # Private Methods
36
+ #-------------------------------------------------------------
37
+ private
38
+
39
+ def root_options
40
+ {
41
+ 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
42
+ 'xmlns:o' => 'urn:schemas-microsoft-com:office:office',
43
+ 'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
44
+ 'xmlns:m' => 'http://schemas.openxmlformats.org/officeDocument/2006/math',
45
+ 'xmlns:v' => 'urn:schemas-microsoft-com:vml',
46
+ 'xmlns:wp' => 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing',
47
+ 'xmlns:w10' => 'urn:schemas-microsoft-com:office:word',
48
+ 'xmlns:w' => 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
49
+ 'xmlns:wne' => 'http://schemas.microsoft.com/office/word/2006/wordml',
50
+ 'xmlns:sl' => 'http://schemas.openxmlformats.org/schemaLibrary/2006/main',
51
+ 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main',
52
+ 'xmlns:pic' => 'http://schemas.openxmlformats.org/drawingml/2006/picture',
53
+ 'xmlns:c' => 'http://schemas.openxmlformats.org/drawingml/2006/chart',
54
+ 'xmlns:lc' => 'http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas',
55
+ 'xmlns:dgm' => 'http://schemas.openxmlformats.org/drawingml/2006/diagram'
56
+ }
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -22,6 +22,7 @@ module Caracal
22
22
  xml['w'].compat do
23
23
  xml['w'].compatSetting({ 'w:val' => '14', 'w:name' => 'compatibilityMode', 'w:uri' => 'http://schemas.microsoft.com/office/word' })
24
24
  end
25
+ xml['w'].updateFields({ 'w:val' => true })
25
26
  end
26
27
  end
27
28
  builder.to_xml(save_options)
@@ -55,4 +56,4 @@ module Caracal
55
56
 
56
57
  end
57
58
  end
58
- end
59
+ end
@@ -31,6 +31,7 @@ module Caracal
31
31
  xml['w'].b({ 'w:val' => (s.style_bold ? '1' : '0') })
32
32
  xml['w'].i({ 'w:val' => (s.style_italic ? '1' : '0') })
33
33
  xml['w'].caps({ 'w:val' => (s.style_caps ? '1' : '0') })
34
+ xml['w'].outlineLvl({ 'w:val' => s.style_outline })
34
35
  xml['w'].smallCaps({ 'w:val' => '0' })
35
36
  xml['w'].strike({ 'w:val' => '0' })
36
37
  xml['w'].color({ 'w:val' => s.style_color })
@@ -75,6 +76,7 @@ module Caracal
75
76
  xml['w'].widowControl({ 'w:val' => '1' })
76
77
  xml['w'].spacing(spacing_options(s)) unless spacing_options(s).nil?
77
78
  xml['w'].contextualSpacing({ 'w:val' => '1' })
79
+ xml['w'].outlineLvl({ 'w:val' => s.style_outline }) unless s.style_outline.nil?
78
80
  xml['w'].jc({ 'w:val' => s.style_align.to_s }) unless s.style_align.nil?
79
81
  xml['w'].ind(indentation_options(s)) unless indentation_options(s).nil?
80
82
  end
@@ -1,3 +1,3 @@
1
1
  module Caracal
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
data/lib/caracal.rb CHANGED
@@ -38,3 +38,27 @@ Caracal::Core::Models::TableCellModel.class_eval do
38
38
  include Caracal::Core::Tables
39
39
  include Caracal::Core::Text
40
40
  end
41
+
42
+ Caracal::Core::Models::PageFlipModel.class_eval do
43
+ include Caracal::Core::Images
44
+ include Caracal::Core::Lists
45
+ include Caracal::Core::Rules
46
+ include Caracal::Core::Tables
47
+ include Caracal::Core::Text
48
+ end
49
+
50
+ Caracal::Core::Models::FooterModel.class_eval do
51
+ include Caracal::Core::Images
52
+ include Caracal::Core::Lists
53
+ include Caracal::Core::Rules
54
+ include Caracal::Core::Tables
55
+ include Caracal::Core::Text
56
+ end
57
+
58
+ Caracal::Core::Models::HeaderModel.class_eval do
59
+ include Caracal::Core::Images
60
+ include Caracal::Core::Lists
61
+ include Caracal::Core::Rules
62
+ include Caracal::Core::Tables
63
+ include Caracal::Core::Text
64
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Fields do
4
+ subject { Caracal::Document.new }
5
+
6
+
7
+ #-------------------------------------------------------------
8
+ # Public Methods
9
+ #-------------------------------------------------------------
10
+
11
+ describe 'public method tests' do
12
+
13
+ # .table
14
+ describe '.field' do
15
+ let!(:size) { subject.contents.size }
16
+
17
+ before { subject.field :table_of_contents }
18
+
19
+ it { expect(subject.contents.size).to eq size + 1 }
20
+ it { expect(subject.contents.last).to be_a(Caracal::Core::Models::FieldModel) }
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Text do
4
+ subject { Caracal::Document.new }
5
+
6
+ #-------------------------------------------------------------
7
+ # Configuration
8
+ #-------------------------------------------------------------
9
+
10
+ describe 'configuration tests' do
11
+
12
+ # accessors
13
+ describe 'accessors' do
14
+ it { expect(subject.footer_content).to be_nil }
15
+ end
16
+ end
17
+
18
+ #-------------------------------------------------------------
19
+ # Public Methods
20
+ #-------------------------------------------------------------
21
+
22
+ describe 'public method tests' do
23
+
24
+ describe '.footer' do
25
+ before { subject.footer }
26
+
27
+ it { expect(subject.footer_content).not_to be_nil }
28
+ it { expect(subject.footer_content).to be_a(Caracal::Core::Models::FooterModel) }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Text do
4
+ subject { Caracal::Document.new }
5
+
6
+ #-------------------------------------------------------------
7
+ # Configuration
8
+ #-------------------------------------------------------------
9
+
10
+ describe 'configuration tests' do
11
+
12
+ # accessors
13
+ describe 'accessors' do
14
+ it { expect(subject.header_content).to be_nil }
15
+ end
16
+ end
17
+
18
+ #-------------------------------------------------------------
19
+ # Public Methods
20
+ #-------------------------------------------------------------
21
+
22
+ describe 'public method tests' do
23
+
24
+ describe '.header' do
25
+ before { subject.header }
26
+
27
+ it { expect(subject.header_content).not_to be_nil }
28
+ it { expect(subject.header_content).to be_a(Caracal::Core::Models::HeaderModel) }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Models::FooterModel do
4
+ subject do
5
+ described_class.new
6
+ end
7
+
8
+ #-------------------------------------------------------------
9
+ # Public Methods
10
+ #-------------------------------------------------------------
11
+
12
+ describe 'public method tests' do
13
+
14
+ #=============== DATA ACCESSORS ====================
15
+
16
+ describe 'data tests' do
17
+
18
+ # .contents
19
+ describe '.contents' do
20
+ it { expect(subject.contents).to be_a(Array) }
21
+ end
22
+ end
23
+
24
+ #=============== VALIDATION ========================
25
+
26
+ describe '.valid?' do
27
+ describe 'when content provided' do
28
+ before { allow(subject).to receive(:contents).and_return(['a']) }
29
+
30
+ it { expect(subject.valid?).to eq true }
31
+ end
32
+
33
+ describe 'when content not provided' do
34
+ before { allow(subject).to receive(:contents).and_return([]) }
35
+
36
+ it { expect(subject.valid?).to eq false }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Models::HeaderModel do
4
+ subject do
5
+ described_class.new
6
+ end
7
+
8
+ #-------------------------------------------------------------
9
+ # Public Methods
10
+ #-------------------------------------------------------------
11
+
12
+ describe 'public method tests' do
13
+
14
+ #=============== DATA ACCESSORS ====================
15
+
16
+ describe 'data tests' do
17
+
18
+ # .contents
19
+ describe '.contents' do
20
+ it { expect(subject.contents).to be_a(Array) }
21
+ end
22
+ end
23
+
24
+ #=============== VALIDATION ========================
25
+
26
+ describe '.valid?' do
27
+ describe 'when content provided' do
28
+ before { allow(subject).to receive(:contents).and_return(['a']) }
29
+
30
+ it { expect(subject.valid?).to eq true }
31
+ end
32
+
33
+ describe 'when content not provided' do
34
+ before { allow(subject).to receive(:contents).and_return([]) }
35
+
36
+ it { expect(subject.valid?).to eq false }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Models::PageFlipModel do
4
+ let(:name) { 'Arial' }
5
+
6
+ subject { described_class.new }
7
+
8
+
9
+ #-------------------------------------------------------------
10
+ # Configuration
11
+ #-------------------------------------------------------------
12
+
13
+ describe 'configuration tests' do
14
+
15
+ describe 'inheritance' do
16
+ it { expect(subject).to be_a(Caracal::Core::Models::BaseModel) }
17
+ end
18
+ end
19
+
20
+ #=============== VALIDATION ===========================
21
+
22
+ describe '.valid?' do
23
+ describe 'when content provided' do
24
+ before { allow(subject).to receive(:contents).and_return(['a']) }
25
+
26
+ it { expect(subject.valid?).to eq true }
27
+ end
28
+ describe 'when content not provided' do
29
+ before { allow(subject).to receive(:contents).and_return([]) }
30
+
31
+ it { expect(subject.valid?).to eq false }
32
+ end
33
+ end
34
+ end
@@ -137,6 +137,23 @@ describe Caracal::Core::Models::ParagraphModel do
137
137
  it { expect(subject.runs.size).to eq length + 1 }
138
138
  end
139
139
 
140
+ # .field
141
+ describe '.field' do
142
+ let!(:length) { subject.runs.length }
143
+
144
+ context ':page' do
145
+ before { subject.field :page }
146
+
147
+ it { expect(subject.runs.size).to eq length + 1 }
148
+ end
149
+
150
+ context ':numpages' do
151
+ before { subject.field :numpages }
152
+
153
+ it { expect(subject.runs.size).to eq length + 1 }
154
+ end
155
+ end
156
+
140
157
  # .bookmark
141
158
  describe '.bookmark_start' do
142
159
  let!(:length) { subject.runs.length }
@@ -149,7 +166,7 @@ describe Caracal::Core::Models::ParagraphModel do
149
166
  describe '.bookmark_end' do
150
167
  let!(:length) { subject.runs.length }
151
168
 
152
- before { subject.bookmark_end {id:'1'}}
169
+ before { subject.bookmark_end(id:'1')}
153
170
 
154
171
  it { expect(subject.runs.size).to eq length + 1 }
155
172
  end
@@ -32,6 +32,7 @@ describe Caracal::Core::Models::StyleModel do
32
32
  it { expect(described_class::DEFAULT_STYLE_LINE).to eq 360 }
33
33
  it { expect(described_class::DEFAULT_STYLE_BASE).to eq 'Normal' }
34
34
  it { expect(described_class::DEFAULT_STYLE_NEXT).to eq 'Normal' }
35
+ it { expect(described_class::DEFAULT_STYLE_OUTLINE).to eq 9 }
35
36
  end
36
37
 
37
38
  # accessors
@@ -53,6 +54,7 @@ describe Caracal::Core::Models::StyleModel do
53
54
  it { expect(subject.style_line).to eq 360 }
54
55
  it { expect(subject.style_base).to eq 'Normal' }
55
56
  it { expect(subject.style_next).to eq 'Normal' }
57
+ it { expect(subject.style_outline).to eq 9 }
56
58
  end
57
59
 
58
60
  end
@@ -146,6 +148,11 @@ describe Caracal::Core::Models::StyleModel do
146
148
 
147
149
  it { expect(subject.style_font).to eq 'Helvetica' }
148
150
  end
151
+ describe '.outline' do
152
+ before { subject.outline(3) }
153
+
154
+ it { expect(subject.style_outline).to eq "3" }
155
+ end
149
156
 
150
157
  # symbols
151
158
  describe '.align' do
@@ -215,7 +222,7 @@ describe Caracal::Core::Models::StyleModel do
215
222
  # .option_keys
216
223
  describe '.option_keys' do
217
224
  let(:actual) { subject.send(:option_keys).sort }
218
- let(:expected) { [:type, :bold, :italic, :underline, :caps, :top, :bottom, :size, :line, :id, :name, :color, :font, :align, :indent_left, :indent_right, :indent_first].sort }
225
+ let(:expected) { [:type, :bold, :italic, :underline, :caps, :top, :bottom, :size, :line, :id, :name, :color, :font, :align, :indent_left, :indent_right, :indent_first, :outline].sort }
219
226
 
220
227
  it { expect(actual).to eq expected }
221
228
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::PageFlips do
4
+ subject { Caracal::Document.new }
5
+
6
+
7
+ #-------------------------------------------------------------
8
+ # Public Methods
9
+ #-------------------------------------------------------------
10
+
11
+ describe 'public method tests' do
12
+
13
+ # .page
14
+ describe '.page_flip' do
15
+ let!(:size) { subject.contents.size }
16
+
17
+ before do
18
+ subject.page_flip do |x|
19
+ x.p
20
+ end
21
+ end
22
+
23
+ it { expect(subject.contents.size).to eq size + 1 }
24
+ it { expect(subject.contents.last).to be_a(Caracal::Core::Models::PageFlipModel) }
25
+ end
26
+ end
27
+ end
@@ -15,7 +15,7 @@ describe Caracal::Core::Relationships do
15
15
 
16
16
  # .default_relationships
17
17
  describe '.default_relationships' do
18
- let(:expected) { [:font, :footer, :numbering, :setting, :style] }
18
+ let(:expected) { [:font, :footer, :header, :numbering, :setting, :style] }
19
19
  let(:actual) { subject.class.default_relationships.map { |r| r[:type] } }
20
20
 
21
21
  it { expect(actual).to eq expected }
@@ -105,7 +105,7 @@ describe Caracal::Core::Relationships do
105
105
  it { expect(subject.relationships.size).to eq default_length }
106
106
  end
107
107
  describe 'when not registered' do
108
- before do
108
+ before do
109
109
  subject.register_relationship(m1)
110
110
  subject.unregister_relationship(m2.relationship_target)
111
111
  end