xmlss 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +10 -16
- data/Rakefile +3 -3
- data/lib/xmlss/version.rb +1 -1
- data/test/cell_test.rb +68 -65
- data/test/column_test.rb +33 -32
- data/test/data_test.rb +70 -63
- data/test/helper.rb +15 -16
- data/test/irb.rb +10 -0
- data/test/item_set_test.rb +18 -17
- data/test/row_test.rb +52 -49
- data/test/style/alignment_test.rb +54 -61
- data/test/style/base_test.rb +90 -80
- data/test/style/border_test.rb +52 -58
- data/test/style/font_test.rb +47 -54
- data/test/style/interior_test.rb +32 -41
- data/test/style/number_format_test.rb +26 -37
- data/test/style/protection_test.rb +24 -28
- data/test/table_test.rb +48 -45
- data/test/workbook_test.rb +51 -46
- data/test/worksheet_test.rb +51 -50
- data/test/xml_test.rb +61 -60
- data/test/xmlss_test.rb +23 -21
- data/xmlss.gemspec +2 -2
- metadata +23 -27
- data/test/env.rb +0 -10
data/test/style/border_test.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
require "
|
1
|
+
require "assert"
|
2
2
|
require 'xmlss/style/border'
|
3
3
|
|
4
|
-
|
4
|
+
module Xmlss::Style
|
5
|
+
class BorderTest < Assert::Context
|
6
|
+
desc "Xmlss::Style::Border"
|
7
|
+
before { @b = Xmlss::Style::Border.new }
|
8
|
+
subject { @b }
|
5
9
|
|
6
|
-
|
7
|
-
subject { Xmlss::Style::Border.new }
|
10
|
+
should have_class_method :position
|
8
11
|
|
9
|
-
should_have_class_method :position
|
10
12
|
{
|
11
13
|
:left => "Left",
|
12
14
|
:top => "Top",
|
@@ -16,11 +18,12 @@ class Xmlss::Style::BorderTest < Test::Unit::TestCase
|
|
16
18
|
:diagonal_right => "DiagonalRight"
|
17
19
|
}.each do |position, value|
|
18
20
|
should "provide the value for the '#{position}' position" do
|
19
|
-
assert_equal value,
|
21
|
+
assert_equal value, Border.position(position)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
should have_class_method :weight
|
26
|
+
|
24
27
|
{
|
25
28
|
:hairline => 0,
|
26
29
|
:thin => 1,
|
@@ -28,11 +31,12 @@ class Xmlss::Style::BorderTest < Test::Unit::TestCase
|
|
28
31
|
:thick => 3
|
29
32
|
}.each do |weight, value|
|
30
33
|
should "provide the value for the '#{weight}' weight" do
|
31
|
-
assert_equal value,
|
34
|
+
assert_equal value, Border.weight(weight)
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
|
-
|
38
|
+
should have_class_method :line_style
|
39
|
+
|
36
40
|
{
|
37
41
|
:none => "None",
|
38
42
|
:continuous => "Continuous",
|
@@ -42,73 +46,63 @@ class Xmlss::Style::BorderTest < Test::Unit::TestCase
|
|
42
46
|
:dash_dot_dot => "DashDotDot"
|
43
47
|
}.each do |style, value|
|
44
48
|
should "provide the value for the '#{style}' line_style" do
|
45
|
-
assert_equal value,
|
49
|
+
assert_equal value, Border.line_style(style)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
|
53
|
+
should have_accessors :color, :position, :weight, :line_style
|
50
54
|
|
51
55
|
should "set it's defaults" do
|
52
56
|
assert_equal nil, subject.color
|
53
57
|
assert_equal nil, subject.position
|
54
|
-
assert_equal
|
55
|
-
assert_equal
|
58
|
+
assert_equal Border.weight(:thin), subject.weight
|
59
|
+
assert_equal Border.line_style(:continuous), subject.line_style
|
56
60
|
end
|
57
61
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
should "should set them correctly" do
|
71
|
-
@attrs.reject{|a, v| [:position, :weight, :line_style].include?(a)}.each do |a,v|
|
72
|
-
assert_equal v, subject.send(a)
|
73
|
-
end
|
74
|
-
assert_equal Xmlss::Style::Border.position(:top), subject.position
|
75
|
-
assert_equal Xmlss::Style::Border.weight(:thick), subject.weight
|
76
|
-
assert_equal Xmlss::Style::Border.line_style(:dot), subject.line_style
|
62
|
+
should "set attrs at init" do
|
63
|
+
attrs = {
|
64
|
+
:color => '#FF0000',
|
65
|
+
:position => :top,
|
66
|
+
:weight => :thick,
|
67
|
+
:line_style => :dot
|
68
|
+
}
|
69
|
+
border = Border.new(attrs)
|
70
|
+
|
71
|
+
attrs.reject{|a, v| [:position, :weight, :line_style].include?(a)}.each do |a,v|
|
72
|
+
assert_equal v, border.send(a)
|
77
73
|
end
|
74
|
+
assert_equal Border.position(:top), border.position
|
75
|
+
assert_equal Border.weight(:thick), border.weight
|
76
|
+
assert_equal Border.line_style(:dot), border.line_style
|
78
77
|
end
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
subject.line_style = :dash_dot
|
85
|
-
end
|
79
|
+
should "set attrs by key" do
|
80
|
+
subject.position = :bottom
|
81
|
+
subject.weight = :medium
|
82
|
+
subject.line_style = :dash_dot
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
assert_equal Xmlss::Style::Border.line_style(:dash_dot), subject.line_style
|
91
|
-
end
|
84
|
+
assert_equal Border.position(:bottom), subject.position
|
85
|
+
assert_equal Border.weight(:medium), subject.weight
|
86
|
+
assert_equal Border.line_style(:dash_dot), subject.line_style
|
92
87
|
end
|
93
88
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
subject.line_style = Xmlss::Style::Border.line_style(:dash_dot)
|
99
|
-
end
|
89
|
+
should "set attrs by value" do
|
90
|
+
subject.position = Border.position(:bottom)
|
91
|
+
subject.weight = Border.weight(:medium)
|
92
|
+
subject.line_style = Border.line_style(:dash_dot)
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
assert_equal Xmlss::Style::Border.line_style(:dash_dot), subject.line_style
|
105
|
-
end
|
94
|
+
assert_equal Border.position(:bottom), subject.position
|
95
|
+
assert_equal Border.weight(:medium), subject.weight
|
96
|
+
assert_equal Border.line_style(:dash_dot), subject.line_style
|
106
97
|
end
|
107
98
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
99
|
+
end
|
100
|
+
|
101
|
+
class BorderXmlTest < BorderTest
|
102
|
+
desc "for generating XML"
|
103
|
+
should have_reader :xml
|
104
|
+
should_build_node
|
112
105
|
|
113
106
|
end
|
107
|
+
|
114
108
|
end
|
data/test/style/font_test.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
require "
|
1
|
+
require "assert"
|
2
2
|
require 'xmlss/style/font'
|
3
3
|
|
4
|
-
|
4
|
+
module Xmlss::Style
|
5
|
+
class FontTest < Assert::Context
|
6
|
+
desc "Xmlss::Style::Font"
|
7
|
+
before { @f = Font.new }
|
8
|
+
subject { @f }
|
5
9
|
|
6
|
-
|
7
|
-
subject { Xmlss::Style::Font.new }
|
10
|
+
should have_class_method :underline
|
8
11
|
|
9
|
-
should_have_class_method :underline
|
10
12
|
{
|
11
13
|
:single => 'Single',
|
12
14
|
:double => 'Double',
|
@@ -18,7 +20,8 @@ class Xmlss::Style::FontTest < Test::Unit::TestCase
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
should have_class_method :alignment
|
24
|
+
|
22
25
|
{
|
23
26
|
:subscript => 'Subscript',
|
24
27
|
:superscript => 'Superscript'
|
@@ -28,10 +31,10 @@ class Xmlss::Style::FontTest < Test::Unit::TestCase
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
should have_accessors :bold, :color, :italic, :size, :strike_through, :shadow
|
35
|
+
should have_accessors :underline, :alignment
|
36
|
+
should have_instance_methods :bold?, :italic?, :strike_through?, :shadow?
|
37
|
+
should have_reader :vertical_align
|
35
38
|
|
36
39
|
should "set it's defaults" do
|
37
40
|
assert_equal false, subject.bold
|
@@ -44,59 +47,49 @@ class Xmlss::Style::FontTest < Test::Unit::TestCase
|
|
44
47
|
assert_equal nil, subject.alignment
|
45
48
|
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
should "should set them correctly" do
|
63
|
-
@attrs.reject{|a, v| [:underline, :alignment].include?(a)}.each do |a,v|
|
64
|
-
assert_equal v, subject.send(a)
|
65
|
-
end
|
66
|
-
assert_equal Xmlss::Style::Font.underline(:single), subject.underline
|
67
|
-
assert_equal Xmlss::Style::Font.alignment(:superscript), subject.alignment
|
50
|
+
should "set attrs at init" do
|
51
|
+
attrs = {
|
52
|
+
:bold => true,
|
53
|
+
:color => '#FF0000',
|
54
|
+
:italic => true,
|
55
|
+
:size => 10,
|
56
|
+
:strike_through => true,
|
57
|
+
:underline => :single,
|
58
|
+
:alignment => :superscript
|
59
|
+
}
|
60
|
+
font = Font.new(attrs)
|
61
|
+
|
62
|
+
attrs.reject{|a, v| [:underline, :alignment].include?(a)}.each do |a,v|
|
63
|
+
assert_equal v, font.send(a)
|
68
64
|
end
|
65
|
+
assert_equal Font.underline(:single), font.underline
|
66
|
+
assert_equal Font.alignment(:superscript), font.alignment
|
69
67
|
end
|
70
68
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
subject.alignment = :subscript
|
75
|
-
end
|
69
|
+
should "set attrs by key" do
|
70
|
+
subject.underline = :double
|
71
|
+
subject.alignment = :subscript
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
assert_equal Xmlss::Style::Font.alignment(:subscript), subject.alignment
|
80
|
-
end
|
73
|
+
assert_equal Font.underline(:double), subject.underline
|
74
|
+
assert_equal Font.alignment(:subscript), subject.alignment
|
81
75
|
end
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
subject.alignment = Xmlss::Style::Font.alignment(:subscript)
|
87
|
-
end
|
77
|
+
should "set attrs by value" do
|
78
|
+
subject.underline = Xmlss::Style::Font.underline(:double)
|
79
|
+
subject.alignment = Xmlss::Style::Font.alignment(:subscript)
|
88
80
|
|
89
|
-
|
90
|
-
|
91
|
-
assert_equal Xmlss::Style::Font.alignment(:subscript), subject.alignment
|
92
|
-
end
|
81
|
+
assert_equal Xmlss::Style::Font.underline(:double), subject.underline
|
82
|
+
assert_equal Xmlss::Style::Font.alignment(:subscript), subject.alignment
|
93
83
|
end
|
94
84
|
|
95
|
-
|
96
|
-
should_have_reader :xml
|
97
|
-
should_build_node
|
98
|
-
should_build_no_attributes_by_default(Xmlss::Style::Font)
|
99
|
-
end
|
85
|
+
end
|
100
86
|
|
87
|
+
class FontXmlTest < FontTest
|
88
|
+
desc "for generating XML"
|
89
|
+
|
90
|
+
should have_reader :xml
|
91
|
+
should_build_node
|
92
|
+
should_build_no_attributes_by_default(Xmlss::Style::Font)
|
101
93
|
end
|
94
|
+
|
102
95
|
end
|
data/test/style/interior_test.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
require "
|
1
|
+
require "assert"
|
2
2
|
require 'xmlss/style/interior'
|
3
3
|
|
4
|
-
|
4
|
+
module Xmlss::Style
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
class InteriorTest < Assert::Context
|
7
|
+
desc "Xmlss::Style::Interior"
|
8
|
+
before { @i = Interior.new }
|
9
|
+
subject { @i }
|
10
|
+
|
11
|
+
should have_class_method :pattern
|
8
12
|
|
9
|
-
should_have_class_method :pattern
|
10
13
|
{
|
11
14
|
:none => "None",
|
12
15
|
:solid => "Solid",
|
@@ -33,7 +36,7 @@ class Xmlss::Style::InteriorTest < Test::Unit::TestCase
|
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
36
|
-
|
39
|
+
should have_accessor :color, :pattern, :pattern_color
|
37
40
|
|
38
41
|
should "set it's defaults" do
|
39
42
|
assert_equal nil, subject.color
|
@@ -41,47 +44,35 @@ class Xmlss::Style::InteriorTest < Test::Unit::TestCase
|
|
41
44
|
assert_equal nil, subject.pattern_color
|
42
45
|
end
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
should "should set them correctly" do
|
54
|
-
assert_equal "#000000", subject.color
|
55
|
-
assert_equal "Solid", subject.pattern
|
56
|
-
assert_equal "#FF0000", subject.pattern_color
|
57
|
-
end
|
47
|
+
should "set attributes at init" do
|
48
|
+
i = Interior.new({
|
49
|
+
:color => "#000000",
|
50
|
+
:pattern => :solid,
|
51
|
+
:pattern_color => "#FF0000"
|
52
|
+
})
|
53
|
+
assert_equal "#000000", i.color
|
54
|
+
assert_equal "Solid", i.pattern
|
55
|
+
assert_equal "#FF0000", i.pattern_color
|
58
56
|
end
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
should "should returm them by value" do
|
66
|
-
assert_equal "Solid", subject.pattern
|
67
|
-
end
|
58
|
+
should "set attrs by key" do
|
59
|
+
subject.pattern = :solid
|
60
|
+
assert_equal "Solid", subject.pattern
|
68
61
|
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
should "should returm them by value" do
|
76
|
-
assert_equal "Solid", subject.pattern
|
77
|
-
end
|
63
|
+
should "set attrs by value" do
|
64
|
+
subject.pattern = "Solid"
|
65
|
+
assert_equal "Solid", subject.pattern
|
78
66
|
end
|
79
67
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class InteriorXmlTest < InteriorTest
|
71
|
+
desc "for generating XML"
|
85
72
|
|
73
|
+
should have_reader :xml
|
74
|
+
should_build_node
|
75
|
+
should_build_no_attributes_by_default(Xmlss::Style::Alignment)
|
86
76
|
end
|
77
|
+
|
87
78
|
end
|
@@ -1,50 +1,39 @@
|
|
1
|
-
require "
|
1
|
+
require "assert"
|
2
2
|
require 'xmlss/style/number_format'
|
3
3
|
|
4
|
-
|
4
|
+
module Xmlss::Style
|
5
|
+
class NumberFormatTest < Assert::Context
|
6
|
+
desc "Xmlss::Style::NumberFormat"
|
7
|
+
before { @nf = NumberFormat.new }
|
8
|
+
subject { @nf }
|
5
9
|
|
6
|
-
|
7
|
-
subject { Xmlss::Style::NumberFormat.new }
|
10
|
+
should have_accessor :format
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
:format => "General"
|
15
|
-
})
|
16
|
-
end
|
17
|
-
|
18
|
-
should "should set them correctly" do
|
19
|
-
assert_equal "General", subject.format
|
20
|
-
end
|
12
|
+
should "set attributes at init" do
|
13
|
+
nf = Xmlss::Style::NumberFormat.new({
|
14
|
+
:format => "General"
|
15
|
+
})
|
16
|
+
assert_equal "General", nf.format
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
should "should returm it by value" do
|
29
|
-
assert_equal "@", subject.format
|
30
|
-
end
|
19
|
+
should "set format by key" do
|
20
|
+
subject.format = "@"
|
21
|
+
assert_equal "@", subject.format
|
31
22
|
end
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
should "should returm it by value" do
|
39
|
-
assert_equal "True/False", subject.format
|
40
|
-
end
|
24
|
+
should "set format by value" do
|
25
|
+
subject.format = "True/False"
|
26
|
+
assert_equal "True/False", subject.format
|
41
27
|
end
|
42
28
|
|
43
|
-
|
44
|
-
should_have_reader :xml
|
45
|
-
should_build_node
|
46
|
-
should_build_no_attributes_by_default(Xmlss::Style::Alignment)
|
47
|
-
end
|
29
|
+
end
|
48
30
|
|
31
|
+
class NumberFormatXmlTest < NumberFormatTest
|
32
|
+
desc "for generating XML"
|
33
|
+
|
34
|
+
should have_reader :xml
|
35
|
+
should_build_node
|
36
|
+
should_build_no_attributes_by_default(Xmlss::Style::Alignment)
|
49
37
|
end
|
38
|
+
|
50
39
|
end
|