rocx 0.5.6 → 0.5.7
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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile.lock +1 -1
- data/lib/rocx.rb +1 -1
- data/lib/rocx/elements/base_container.rb +17 -2
- data/lib/rocx/elements/paragraph.rb +33 -21
- data/lib/rocx/elements/run.rb +2 -2
- data/lib/rocx/elements/style.rb +19 -0
- data/lib/rocx/parts/base_part.rb +4 -0
- data/lib/rocx/parts/content_types.rb +2 -6
- data/lib/rocx/parts/document.rb +2 -3
- data/lib/rocx/parts/global_rels.rb +2 -3
- data/lib/rocx/parts/rels.rb +2 -3
- data/lib/rocx/parts/settings.rb +2 -3
- data/lib/rocx/parts/styles.rb +2 -3
- data/lib/rocx/properties/alignment.rb +1 -1
- data/lib/rocx/properties/attribute_builder.rb +283 -0
- data/lib/rocx/properties/base_property.rb +4 -0
- data/lib/rocx/properties/border.rb +32 -0
- data/lib/rocx/properties/borders.rb +48 -0
- data/lib/rocx/properties/compress_punctuation.rb +11 -0
- data/lib/rocx/properties/frame.rb +70 -0
- data/lib/rocx/properties/indentation.rb +1 -1
- data/lib/rocx/properties/numbering.rb +28 -0
- data/lib/rocx/properties/shading.rb +75 -0
- data/lib/rocx/properties/spacing.rb +38 -0
- data/lib/rocx/properties/tab.rb +77 -0
- data/lib/rocx/properties/tabs.rb +55 -0
- data/lib/rocx/properties/text_direction.rb +15 -0
- data/lib/rocx/properties/textbox_tight_wrap.rb +15 -0
- data/lib/rocx/properties/vertical_alignment.rb +19 -0
- data/lib/rocx/version.rb +1 -1
- data/rocx.gemspec +1 -0
- data/test/package_test.rb +6 -6
- data/test/properties/auto_adjust_right_indent_test.rb +4 -4
- data/test/properties/auto_space_de_test.rb +4 -4
- data/test/properties/auto_space_dn_test.rb +4 -4
- data/test/properties/bidi_test.rb +4 -4
- data/test/properties/bold_test.rb +4 -4
- data/test/properties/border_test.rb +216 -0
- data/test/properties/borders_test.rb +95 -0
- data/test/properties/compress_punctuation_test.rb +50 -0
- data/test/properties/conditional_formatting_test.rb +4 -4
- data/test/properties/contextual_spacing_test.rb +4 -4
- data/test/properties/div_id_test.rb +3 -3
- data/test/properties/frame_test.rb +497 -0
- data/test/properties/italics_test.rb +4 -4
- data/test/properties/keep_lines_test.rb +4 -4
- data/test/properties/keep_next_test.rb +4 -4
- data/test/properties/kinsoku_test.rb +4 -4
- data/test/properties/mirror_indent_test.rb +4 -4
- data/test/properties/numbering_test.rb +86 -0
- data/test/properties/outline_level_test.rb +4 -4
- data/test/properties/overflow_punctuation_test.rb +4 -4
- data/test/properties/page_break_before_test.rb +4 -4
- data/test/properties/shading_test.rb +225 -0
- data/test/properties/snap_to_grid_test.rb +4 -4
- data/test/properties/spacing_test.rb +248 -0
- data/test/properties/style_test.rb +30 -0
- data/test/properties/supress_auto_hyphens_test.rb +4 -4
- data/test/properties/supress_line_numbers_test.rb +4 -4
- data/test/properties/supress_overlap_test.rb +4 -4
- data/test/properties/tab_test.rb +63 -0
- data/test/properties/tabs_test.rb +54 -0
- data/test/properties/text_direction_test.rb +100 -0
- data/test/properties/textbox_tight_wrap_test.rb +88 -0
- data/test/properties/vertical_alignment_test.rb +88 -0
- data/test/properties/widow_control_test.rb +4 -4
- data/test/properties/word_wrap_test.rb +4 -4
- data/test/test_helper.rb +2 -5
- metadata +45 -3
@@ -5,7 +5,7 @@ class ItalicsTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@italics =
|
8
|
+
@italics = Italics.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class ItalicsTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@italics =
|
22
|
+
@italics = Italics.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class ItalicsTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@italics =
|
32
|
+
@italics = Italics.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class ItalicsTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@italics =
|
42
|
+
@italics = Italics.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -5,7 +5,7 @@ class KeepLinesTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@keep_lines =
|
8
|
+
@keep_lines = KeepLines.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class KeepLinesTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@keep_lines =
|
22
|
+
@keep_lines = KeepLines.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class KeepLinesTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@keep_lines =
|
32
|
+
@keep_lines = KeepLines.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class KeepLinesTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@keep_lines =
|
42
|
+
@keep_lines = KeepLines.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -5,7 +5,7 @@ class KeepNextTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@keep_next =
|
8
|
+
@keep_next = KeepNext.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class KeepNextTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@keep_next =
|
22
|
+
@keep_next = KeepNext.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class KeepNextTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@keep_next =
|
32
|
+
@keep_next = KeepNext.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class KeepNextTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@keep_next =
|
42
|
+
@keep_next = KeepNext.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -5,7 +5,7 @@ class KinsokuTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@kinsoku =
|
8
|
+
@kinsoku = Kinsoku.new(:on)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class KinsokuTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is on, it" do
|
21
21
|
setup do
|
22
|
-
@kinsoku =
|
22
|
+
@kinsoku = Kinsoku.new(:on)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML to that effect" do
|
@@ -29,7 +29,7 @@ class KinsokuTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is off, it" do
|
31
31
|
setup do
|
32
|
-
@kinsoku =
|
32
|
+
@kinsoku = Kinsoku.new(:off)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "return XML to that effect" do
|
@@ -39,7 +39,7 @@ class KinsokuTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@kinsoku =
|
42
|
+
@kinsoku = Kinsoku.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -5,7 +5,7 @@ class MirrorIndentTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@mirror_indent =
|
8
|
+
@mirror_indent = MirrorIndent.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class MirrorIndentTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@mirror_indent =
|
22
|
+
@mirror_indent = MirrorIndent.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class MirrorIndentTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@mirror_indent =
|
32
|
+
@mirror_indent = MirrorIndent.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class MirrorIndentTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@mirror_indent =
|
42
|
+
@mirror_indent = MirrorIndent.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class NumberingTest < PropertyTest
|
4
|
+
attr_reader :numbering
|
5
|
+
|
6
|
+
context "always" do
|
7
|
+
setup do
|
8
|
+
@numbering = Numbering.new
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have the right name" do
|
12
|
+
assert_equal "numbering", numbering.name
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have the right tag" do
|
16
|
+
assert_equal :numPr, numbering.tag
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "for the level property, it" do
|
21
|
+
setup do
|
22
|
+
@numbering = Numbering.new
|
23
|
+
end
|
24
|
+
|
25
|
+
should "allow positive integers" do
|
26
|
+
assert_nothing_raised do
|
27
|
+
numbering.level = 24
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "not allow anything else" do
|
32
|
+
assert_raises ArgumentError do
|
33
|
+
numbering.level = -24
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_raises ArgumentError do
|
37
|
+
numbering.level = :big
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "for the id property, it" do
|
43
|
+
setup do
|
44
|
+
@numbering = Numbering.new
|
45
|
+
end
|
46
|
+
|
47
|
+
should "allow positive integers" do
|
48
|
+
assert_nothing_raised do
|
49
|
+
numbering.id = 24
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
should "not allow anything else" do
|
54
|
+
assert_raises ArgumentError do
|
55
|
+
numbering.id = -24
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_raises ArgumentError do
|
59
|
+
numbering.id = :big
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with no attributes set, it" do
|
65
|
+
setup do
|
66
|
+
@numbering = Numbering.new
|
67
|
+
end
|
68
|
+
|
69
|
+
should "not output any XML" do
|
70
|
+
assert_equal "", xml(numbering)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "with valid attributes set, it" do
|
75
|
+
setup do
|
76
|
+
@numbering = Numbering.new
|
77
|
+
numbering.level = 4
|
78
|
+
numbering.id = 0
|
79
|
+
end
|
80
|
+
|
81
|
+
should "return the correct XML" do
|
82
|
+
assert_equal "<w:numPr>\n <w:ilvl w:val=\"4\"/>\n <w:numId w:val=\"0\"/>\n </w:numPr>", xml(numbering)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -5,7 +5,7 @@ class OutlineLevelTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@outline_level =
|
8
|
+
@outline_level = OutlineLevel.new(0)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -20,7 +20,7 @@ class OutlineLevelTest < PropertyTest
|
|
20
20
|
context "with non-integer values, it" do
|
21
21
|
should "raise an error" do
|
22
22
|
assert_raises ArgumentError do
|
23
|
-
@outline_level =
|
23
|
+
@outline_level = OutlineLevel.new(:big)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -28,14 +28,14 @@ class OutlineLevelTest < PropertyTest
|
|
28
28
|
context "with integers less than 0, it" do
|
29
29
|
should "raise an error" do
|
30
30
|
assert_raises ArgumentError do
|
31
|
-
@outline_level =
|
31
|
+
@outline_level = OutlineLevel.new(-1)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with valid value, it" do
|
37
37
|
setup do
|
38
|
-
@outline_level =
|
38
|
+
@outline_level = OutlineLevel.new(2)
|
39
39
|
end
|
40
40
|
|
41
41
|
should "return the proper XML" do
|
@@ -5,7 +5,7 @@ class OverflowPunctuationTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@overflow_punctuation =
|
8
|
+
@overflow_punctuation = OverflowPunctuation.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class OverflowPunctuationTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@overflow_punctuation =
|
22
|
+
@overflow_punctuation = OverflowPunctuation.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class OverflowPunctuationTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@overflow_punctuation =
|
32
|
+
@overflow_punctuation = OverflowPunctuation.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class OverflowPunctuationTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@overflow_punctuation =
|
42
|
+
@overflow_punctuation = OverflowPunctuation.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -5,7 +5,7 @@ class PageBreakBeforeTest < PropertyTest
|
|
5
5
|
|
6
6
|
context "always" do
|
7
7
|
setup do
|
8
|
-
@page_break_before =
|
8
|
+
@page_break_before = PageBreakBefore.new(false)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "have the right tag" do
|
@@ -19,7 +19,7 @@ class PageBreakBeforeTest < PropertyTest
|
|
19
19
|
|
20
20
|
context "when the value is true, it" do
|
21
21
|
setup do
|
22
|
-
@page_break_before =
|
22
|
+
@page_break_before = PageBreakBefore.new(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return XML" do
|
@@ -29,7 +29,7 @@ class PageBreakBeforeTest < PropertyTest
|
|
29
29
|
|
30
30
|
context "when the value is false, it" do
|
31
31
|
setup do
|
32
|
-
@page_break_before =
|
32
|
+
@page_break_before = PageBreakBefore.new(false)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "not return XML" do
|
@@ -39,7 +39,7 @@ class PageBreakBeforeTest < PropertyTest
|
|
39
39
|
|
40
40
|
context "when the value is nil, it" do
|
41
41
|
setup do
|
42
|
-
@page_break_before =
|
42
|
+
@page_break_before = PageBreakBefore.new(nil)
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not return XML" do
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ShadingTest < PropertyTest
|
4
|
+
attr_reader :shading
|
5
|
+
|
6
|
+
context "always" do
|
7
|
+
setup do
|
8
|
+
@shading = Shading.new
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have the right name" do
|
12
|
+
assert_equal "shading", shading.name
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have the right tag" do
|
16
|
+
assert_equal :shd, shading.tag
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "for the color attribute, it" do
|
21
|
+
setup do
|
22
|
+
@shading = Shading.new
|
23
|
+
end
|
24
|
+
|
25
|
+
should "allow hex color values" do
|
26
|
+
assert_nothing_raised do
|
27
|
+
shading.color = "4F81BD"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "allow :auto" do
|
32
|
+
assert_nothing_raised do
|
33
|
+
shading.color = :auto
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should "not allow anything else" do
|
38
|
+
assert_raises ArgumentError do
|
39
|
+
shading.color = "green"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "for the fill attribute, it" do
|
45
|
+
setup do
|
46
|
+
@shading = Shading.new
|
47
|
+
end
|
48
|
+
|
49
|
+
should "allow hex color values" do
|
50
|
+
assert_nothing_raised do
|
51
|
+
shading.fill = "4F81BD"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
should "allow :auto" do
|
56
|
+
assert_nothing_raised do
|
57
|
+
shading.fill = :auto
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
should "not allow anything else" do
|
62
|
+
assert_raises ArgumentError do
|
63
|
+
shading.fill = "green"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "for the theme color attribute, it" do
|
69
|
+
setup do
|
70
|
+
@shading = Shading.new
|
71
|
+
end
|
72
|
+
|
73
|
+
should "only allow valid theme colors" do
|
74
|
+
assert_nothing_raised do
|
75
|
+
shading.theme_color = :hyperlink
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
should "not allow anything else" do
|
80
|
+
assert ArgumentError do
|
81
|
+
shading.theme_color = :lens_flare
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "for the theme fill attribute, it" do
|
87
|
+
setup do
|
88
|
+
@shading = Shading.new
|
89
|
+
end
|
90
|
+
|
91
|
+
should "only allow valid theme colors" do
|
92
|
+
assert_nothing_raised do
|
93
|
+
shading.theme_fill = :hyperlink
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
should "not allow anything else" do
|
98
|
+
assert ArgumentError do
|
99
|
+
shading.theme_fill = :lens_flare
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "for the theme fill shade attribute" do
|
105
|
+
setup do
|
106
|
+
@shading = Shading.new
|
107
|
+
end
|
108
|
+
|
109
|
+
should "only allow 2-digit hex colors" do
|
110
|
+
assert_nothing_raised do
|
111
|
+
shading.theme_fill_shade = "BF"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
should "not allow anything else" do
|
116
|
+
assert ArgumentError do
|
117
|
+
shading.theme_fill_shade = :dark
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "for the theme fill tint attribute" do
|
123
|
+
setup do
|
124
|
+
@shading = Shading.new
|
125
|
+
end
|
126
|
+
|
127
|
+
should "only allow 2-digit hex colors" do
|
128
|
+
assert_nothing_raised do
|
129
|
+
shading.theme_fill_tint = "BF"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
should "not allow anything else" do
|
134
|
+
assert ArgumentError do
|
135
|
+
shading.theme_fill_tint = :dark
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "for the theme shade attribute, it" do
|
141
|
+
setup do
|
142
|
+
@shading = Shading.new
|
143
|
+
end
|
144
|
+
|
145
|
+
should "only allow 2-digit hex colors" do
|
146
|
+
assert_nothing_raised do
|
147
|
+
shading.theme_shade = "BF"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
should "not allow anything else" do
|
152
|
+
assert ArgumentError do
|
153
|
+
shading.theme_shade = :dark
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "for the theme tint attribute, it" do
|
159
|
+
setup do
|
160
|
+
@shading = Shading.new
|
161
|
+
end
|
162
|
+
|
163
|
+
should "only allow 2-digit hex colors" do
|
164
|
+
assert_nothing_raised do
|
165
|
+
shading.theme_tint = "BF"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
should "not allow anything else" do
|
170
|
+
assert ArgumentError do
|
171
|
+
shading.theme_tint = :dark
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "for the pattern attribute, it" do
|
177
|
+
setup do
|
178
|
+
@shading = Shading.new
|
179
|
+
end
|
180
|
+
|
181
|
+
should "allow valid values" do
|
182
|
+
assert_nothing_raised do
|
183
|
+
shading.pattern = :pct90
|
184
|
+
end
|
185
|
+
|
186
|
+
assert_nothing_raised do
|
187
|
+
shading.pattern = :solid
|
188
|
+
end
|
189
|
+
|
190
|
+
assert_nothing_raised do
|
191
|
+
shading.pattern = :vertStripe
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
should "not allow non-valid values" do
|
196
|
+
assert_raises ArgumentError do
|
197
|
+
shading.pattern = :somethingIJustMadeUp
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "with no attributes set, it" do
|
203
|
+
setup do
|
204
|
+
@shading = Shading.new
|
205
|
+
end
|
206
|
+
|
207
|
+
should "not return any XML" do
|
208
|
+
assert_equal "", xml(shading)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context "with attributes set to valid values, it" do
|
213
|
+
setup do
|
214
|
+
@shading = Shading.new
|
215
|
+
shading.pattern = :pct20
|
216
|
+
shading.theme_color = :accent6
|
217
|
+
shading.theme_fill = :accent3
|
218
|
+
end
|
219
|
+
|
220
|
+
should "return the correct XML" do
|
221
|
+
assert_equal "<w:shd w:themeColor=\"accent6\" w:themeFill=\"accent3\" w:val=\"pct20\"/>", xml(shading)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|