xmlss 1.0.0.rc.4 → 1.0.0
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.
- data/.gitignore +18 -2
- data/Gemfile +4 -5
- data/LICENSE.txt +22 -0
- data/{README.rdoc → README.md} +74 -71
- data/Rakefile +1 -7
- data/lib/xmlss/element/cell.rb +5 -0
- data/lib/xmlss/element/worksheet.rb +1 -0
- data/lib/xmlss/version.rb +1 -1
- data/lib/xmlss/writer.rb +53 -60
- data/test/helper.rb +6 -3
- data/test/unit/element/cell_tests.rb +124 -0
- data/test/{element/column_test.rb → unit/element/column_tests.rb} +14 -12
- data/test/{element/row_test.rb → unit/element/row_tests.rb} +14 -13
- data/test/{element/worksheet_test.rb → unit/element/worksheet_tests.rb} +16 -11
- data/test/{element_stack_test.rb → unit/element_stack_tests.rb} +5 -13
- data/test/{style/alignment_test.rb → unit/style/alignment_tests.rb} +17 -16
- data/test/{style/base_test.rb → unit/style/base_tests.rb} +7 -7
- data/test/{style/border_test.rb → unit/style/border_tests.rb} +18 -24
- data/test/{style/font_test.rb → unit/style/font_tests.rb} +8 -7
- data/test/{style/interior_test.rb → unit/style/interior_tests.rb} +6 -6
- data/test/{style/number_format_test.rb → unit/style/number_format_tests.rb} +6 -5
- data/test/{style/protection_test.rb → unit/style/protection_tests.rb} +2 -3
- data/test/{workbook_test.rb → unit/workbook_tests.rb} +2 -2
- data/test/{writer_test.rb → unit/writer_tests.rb} +20 -32
- data/xmlss.gemspec +20 -18
- metadata +58 -85
- data/Gemfile.lock +0 -33
- data/test/element/cell_test.rb +0 -117
- data/test/irb.rb +0 -10
- data/test/thing.rb +0 -9
@@ -0,0 +1,124 @@
|
|
1
|
+
require "assert"
|
2
|
+
require 'xmlss/element/cell'
|
3
|
+
|
4
|
+
require 'enumeration/assert_macros'
|
5
|
+
|
6
|
+
class Xmlss::Element::Cell
|
7
|
+
|
8
|
+
class CellTests < Assert::Context
|
9
|
+
include Enumeration::AssertMacros
|
10
|
+
|
11
|
+
desc "Xmlss::Element::Cell"
|
12
|
+
before { @c = Xmlss::Element::Cell.new }
|
13
|
+
subject { @c }
|
14
|
+
|
15
|
+
should be_styled
|
16
|
+
should have_class_method :writer
|
17
|
+
should have_accessor :index, :formula, :href, :merge_across, :merge_down
|
18
|
+
|
19
|
+
should have_enum :type, {
|
20
|
+
:number => "Number",
|
21
|
+
:date_time => "DateTime",
|
22
|
+
:boolean => "Boolean",
|
23
|
+
:string => "String",
|
24
|
+
:error => "Error"
|
25
|
+
}
|
26
|
+
|
27
|
+
should have_accessor :data
|
28
|
+
should have_instance_method :data_xml_value
|
29
|
+
|
30
|
+
should "know its writer hook" do
|
31
|
+
assert_equal :cell, subject.class.writer
|
32
|
+
end
|
33
|
+
|
34
|
+
should "set it's defaults" do
|
35
|
+
assert_nil subject.formula
|
36
|
+
assert_nil subject.href
|
37
|
+
assert_nil subject.merge_across
|
38
|
+
assert_nil subject.merge_down
|
39
|
+
|
40
|
+
assert_equal Xmlss::Element::Cell.type(:string), subject.type
|
41
|
+
assert_equal "", subject.data
|
42
|
+
end
|
43
|
+
|
44
|
+
should "bark when setting non Fixnum indices" do
|
45
|
+
assert_raises ArgumentError do
|
46
|
+
Xmlss::Element::Cell.new({:index => "do it"})
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_raises ArgumentError do
|
50
|
+
Xmlss::Element::Cell.new({:index => 2.5})
|
51
|
+
end
|
52
|
+
|
53
|
+
assert_nothing_raised do
|
54
|
+
Xmlss::Element::Cell.new({:index => 2})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
should "bark when setting non Fixnum merge attrs" do
|
59
|
+
assert_raises ArgumentError do
|
60
|
+
Xmlss::Element::Cell.new({:merge_across => "do it"})
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_raises ArgumentError do
|
64
|
+
Xmlss::Element::Cell.new({:merge_down => 2.5})
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_nothing_raised do
|
68
|
+
Xmlss::Element::Cell.new({:merge_across => 2})
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_nothing_raised do
|
72
|
+
Xmlss::Element::Cell.new({:merge_down => 3})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
should "nil out merge/index values that are <= 0" do
|
77
|
+
[:index, :merge_across, :merge_down].each do |a|
|
78
|
+
assert_equal nil, Xmlss::Element::Cell.new({a => -1}).send(a)
|
79
|
+
assert_equal nil, Xmlss::Element::Cell.new({a => 0}).send(a)
|
80
|
+
assert_equal 1, Xmlss::Element::Cell.new({a => 1}).send(a)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
should "generate it's data xml value" do
|
85
|
+
assert_equal "12", Xmlss::Element::Cell.new(12).data_xml_value
|
86
|
+
assert_equal "string", Xmlss::Element::Cell.new(:data => "string").data_xml_value
|
87
|
+
assert_equal "2011-03-01T00:00:00", Xmlss::Element::Cell.new(DateTime.parse('2011/03/01')).data_xml_value
|
88
|
+
assert_equal "2011-03-01T00:00:00", Xmlss::Element::Cell.new(Date.parse('2011/03/01')).data_xml_value
|
89
|
+
time = Time.now
|
90
|
+
assert_equal time.strftime("%Y-%m-%dT%H:%M:%S"), Xmlss::Element::Cell.new(time).data_xml_value
|
91
|
+
assert_equal 1, Xmlss::Element::Cell.new(true).data_xml_value
|
92
|
+
assert_equal 0, Xmlss::Element::Cell.new(false).data_xml_value
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
class ExplicitDataTest < CellTests
|
98
|
+
desc "when using explicit data type"
|
99
|
+
subject do
|
100
|
+
Xmlss::Element::Cell.new(12, {:type => :string})
|
101
|
+
end
|
102
|
+
|
103
|
+
should "should ignore the data value's implied type" do
|
104
|
+
assert_equal Xmlss::Element::Cell.type(:string), subject.type
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
class NoTypeDataTest < CellTests
|
110
|
+
desc "when no data type is specified"
|
111
|
+
|
112
|
+
should "cast types for Number, DateTime, Boolean, String" do
|
113
|
+
assert_equal Xmlss::Element::Cell.type(:number), Xmlss::Element::Cell.new(12).type
|
114
|
+
assert_equal Xmlss::Element::Cell.type(:number), Xmlss::Element::Cell.new(:data => 123.45).type
|
115
|
+
assert_equal Xmlss::Element::Cell.type(:date_time), Xmlss::Element::Cell.new(Time.now).type
|
116
|
+
assert_equal Xmlss::Element::Cell.type(:boolean), Xmlss::Element::Cell.new(true).type
|
117
|
+
assert_equal Xmlss::Element::Cell.type(:boolean), Xmlss::Element::Cell.new(false).type
|
118
|
+
assert_equal Xmlss::Element::Cell.type(:string), Xmlss::Element::Cell.new("a string").type
|
119
|
+
assert_equal Xmlss::Element::Cell.type(:string), Xmlss::Element::Cell.new(:data => :symbol).type
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require 'xmlss/element/column'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Xmlss::Element::Column
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Xmlss::Element::Column"
|
8
|
+
before { @c = Xmlss::Element::Column.new }
|
9
9
|
subject { @c }
|
10
10
|
|
11
11
|
should be_styled
|
@@ -25,21 +25,23 @@ module Xmlss::Element
|
|
25
25
|
|
26
26
|
should "bark when setting non Numeric width" do
|
27
27
|
assert_raises ArgumentError do
|
28
|
-
Column.new({:width => "do it"})
|
28
|
+
Xmlss::Element::Column.new({:width => "do it"})
|
29
29
|
end
|
30
|
+
|
30
31
|
assert_nothing_raised do
|
31
|
-
Column.new({:width => 2})
|
32
|
+
Xmlss::Element::Column.new({:width => 2})
|
32
33
|
end
|
34
|
+
|
33
35
|
assert_nothing_raised do
|
34
|
-
Column.new({:width => 3.5})
|
36
|
+
Xmlss::Element::Column.new({:width => 3.5})
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
should "nil out height values that are < 0" do
|
39
|
-
assert_equal nil, Column.new({:width => -1.2}).width
|
40
|
-
assert_equal nil, Column.new({:width => -1}).width
|
41
|
-
assert_equal 0,
|
42
|
-
assert_equal 1.2, Column.new({:width => 1.2}).width
|
41
|
+
assert_equal nil, Xmlss::Element::Column.new({:width => -1.2}).width
|
42
|
+
assert_equal nil, Xmlss::Element::Column.new({:width => -1}).width
|
43
|
+
assert_equal 0, Xmlss::Element::Column.new({:width => 0}).width
|
44
|
+
assert_equal 1.2, Xmlss::Element::Column.new({:width => 1.2}).width
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require 'xmlss/element/row'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Xmlss::Element::Row
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Xmlss::Element::Row"
|
8
|
+
before { @row = Xmlss::Element::Row.new }
|
9
9
|
subject { @row }
|
10
10
|
|
11
11
|
should be_styled
|
@@ -13,7 +13,6 @@ module Xmlss::Element
|
|
13
13
|
should have_accessors :height, :auto_fit_height, :autofit, :hidden
|
14
14
|
should have_readers :autofit?, :hidden?
|
15
15
|
|
16
|
-
|
17
16
|
should "know its writer hook" do
|
18
17
|
assert_equal :row, subject.class.writer
|
19
18
|
end
|
@@ -26,21 +25,23 @@ module Xmlss::Element
|
|
26
25
|
|
27
26
|
should "bark when setting non Numeric height" do
|
28
27
|
assert_raises ArgumentError do
|
29
|
-
Row.new({:height => "do it"})
|
28
|
+
Xmlss::Element::Row.new({:height => "do it"})
|
30
29
|
end
|
30
|
+
|
31
31
|
assert_nothing_raised do
|
32
|
-
Row.new({:height => 2})
|
32
|
+
Xmlss::Element::Row.new({:height => 2})
|
33
33
|
end
|
34
|
+
|
34
35
|
assert_nothing_raised do
|
35
|
-
Row.new({:height => 3.5})
|
36
|
+
Xmlss::Element::Row.new({:height => 3.5})
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
should "nil out height values that are < 0" do
|
40
|
-
assert_equal nil, Row.new({:height => -1.2}).height
|
41
|
-
assert_equal nil, Row.new({:height => -1}).height
|
42
|
-
assert_equal 0,
|
43
|
-
assert_equal 1.2, Row.new({:height => 1.2}).height
|
41
|
+
assert_equal nil, Xmlss::Element::Row.new({:height => -1.2}).height
|
42
|
+
assert_equal nil, Xmlss::Element::Row.new({:height => -1}).height
|
43
|
+
assert_equal 0, Xmlss::Element::Row.new({:height => 0}).height
|
44
|
+
assert_equal 1.2, Xmlss::Element::Row.new({:height => 1.2}).height
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require 'xmlss/element/worksheet'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Xmlss::Element::Worksheet
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Xmlss::Element::Worksheet"
|
8
|
+
before { @wksht = Xmlss::Element::Worksheet.new('sheet') }
|
9
9
|
subject { @wksht }
|
10
10
|
|
11
11
|
should have_class_method :writer
|
@@ -21,25 +21,30 @@ module Xmlss::Element
|
|
21
21
|
|
22
22
|
should "filter name chars" do
|
23
23
|
# worksheet name cannot contain: /, \, :, ;, * or start with '['
|
24
|
-
assert_equal "test test", Worksheet.new("test/ test").name
|
25
|
-
assert_equal "test test", Worksheet.new("tes\\t test").name
|
26
|
-
assert_equal "test test", Worksheet.new("te:st test:").name
|
27
|
-
|
24
|
+
assert_equal "test test", Xmlss::Element::Worksheet.new("test/ test").name
|
25
|
+
assert_equal "test test", Xmlss::Element::Worksheet.new("tes\\t test").name
|
26
|
+
assert_equal "test test", Xmlss::Element::Worksheet.new("te:st test:").name
|
27
|
+
|
28
|
+
ws = Xmlss::Element::Worksheet.new("te;st ;test")
|
28
29
|
assert_equal "test test", ws.name
|
30
|
+
|
29
31
|
ws.name = "t*est test"
|
30
32
|
assert_equal "test test", ws.name
|
33
|
+
|
31
34
|
ws.name = "[te]st test"
|
32
35
|
assert_equal "te]st test", ws.name
|
36
|
+
|
33
37
|
ws.name = "t[e]st test"
|
34
38
|
assert_equal "t[e]st test", ws.name
|
35
39
|
end
|
36
40
|
|
37
41
|
should "complain if given a name longer than 31 chars" do
|
38
42
|
assert_raises ArgumentError do
|
39
|
-
Worksheet.new('a'*32)
|
43
|
+
Xmlss::Element::Worksheet.new('a'*32)
|
40
44
|
end
|
45
|
+
|
41
46
|
assert_nothing_raised do
|
42
|
-
Worksheet.new('a'*31)
|
47
|
+
Xmlss::Element::Worksheet.new('a'*31)
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'assert'
|
2
|
-
|
3
2
|
require 'xmlss/element_stack'
|
3
|
+
|
4
4
|
require 'xmlss/element/cell'
|
5
5
|
require 'xmlss/writer'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
class Xmlss::ElementStack
|
10
8
|
|
11
9
|
class ElementStackTests < Assert::Context
|
12
10
|
|
@@ -19,9 +17,9 @@ module Xmlss
|
|
19
17
|
|
20
18
|
desc "an element stack"
|
21
19
|
before do
|
22
|
-
@cell1 = Element::Cell.new("1")
|
23
|
-
@cell2 = Element::Cell.new("2")
|
24
|
-
@es
|
20
|
+
@cell1 = Xmlss::Element::Cell.new("1")
|
21
|
+
@cell2 = Xmlss::Element::Cell.new("2")
|
22
|
+
@es = Xmlss::ElementStack.new(TestWriter.new(@test_io = ''), 'tests')
|
25
23
|
end
|
26
24
|
subject { @es }
|
27
25
|
|
@@ -39,8 +37,6 @@ module Xmlss
|
|
39
37
|
|
40
38
|
end
|
41
39
|
|
42
|
-
|
43
|
-
|
44
40
|
class StackTests < ElementStackTests
|
45
41
|
|
46
42
|
should "push elements onto the stack" do
|
@@ -77,8 +73,6 @@ module Xmlss
|
|
77
73
|
|
78
74
|
end
|
79
75
|
|
80
|
-
|
81
|
-
|
82
76
|
class WriterTests < ElementStackTests
|
83
77
|
should "open the current element element when a new element is pushed" do
|
84
78
|
expected = "|written: Xmlss::Element::Cell #{@cell1.object_id}"
|
@@ -112,6 +106,4 @@ module Xmlss
|
|
112
106
|
|
113
107
|
end
|
114
108
|
|
115
|
-
|
116
|
-
|
117
109
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require "assert"
|
2
|
+
require 'xmlss/style/alignment'
|
3
|
+
|
2
4
|
require 'enumeration/assert_macros'
|
3
5
|
|
4
|
-
|
6
|
+
class Xmlss::Style::Alignment
|
5
7
|
|
6
|
-
|
7
|
-
class AlignmentTest < Assert::Context
|
8
|
+
class UnitTests < Assert::Context
|
8
9
|
include Enumeration::AssertMacros
|
9
10
|
|
10
11
|
desc "Xmlss::Style::Alignment"
|
11
|
-
before { @a = Alignment.new }
|
12
|
+
before { @a = Xmlss::Style::Alignment.new }
|
12
13
|
subject { @a }
|
13
14
|
|
14
15
|
should have_enum :horizontal, {
|
@@ -41,15 +42,15 @@ module Xmlss::Style
|
|
41
42
|
end
|
42
43
|
|
43
44
|
should "reject invalid rotate alignments" do
|
44
|
-
assert_equal nil, Alignment.new({:rotate => 100}).rotate
|
45
|
-
assert_equal 90, Alignment.new({:rotate => 90}).rotate
|
46
|
-
assert_equal 0, Alignment.new({:rotate => 0}).rotate
|
47
|
-
assert_equal -90, Alignment.new({:rotate => -90}).rotate
|
48
|
-
assert_equal nil, Alignment.new({:rotate => -100}).rotate
|
49
|
-
assert_equal 0, Alignment.new({:rotate => 0.2}).rotate
|
50
|
-
assert_equal 1, Alignment.new({:rotate => 0.5}).rotate
|
51
|
-
assert_equal nil, Alignment.new({:rotate => "poo"}).rotate
|
52
|
-
assert_equal nil, Alignment.new({:rotate => :poo}).rotate
|
45
|
+
assert_equal nil, Xmlss::Style::Alignment.new({:rotate => 100}).rotate
|
46
|
+
assert_equal 90, Xmlss::Style::Alignment.new({:rotate => 90}).rotate
|
47
|
+
assert_equal 0, Xmlss::Style::Alignment.new({:rotate => 0}).rotate
|
48
|
+
assert_equal -90, Xmlss::Style::Alignment.new({:rotate => -90}).rotate
|
49
|
+
assert_equal nil, Xmlss::Style::Alignment.new({:rotate => -100}).rotate
|
50
|
+
assert_equal 0, Xmlss::Style::Alignment.new({:rotate => 0.2}).rotate
|
51
|
+
assert_equal 1, Xmlss::Style::Alignment.new({:rotate => 0.5}).rotate
|
52
|
+
assert_equal nil, Xmlss::Style::Alignment.new({:rotate => "poo"}).rotate
|
53
|
+
assert_equal nil, Xmlss::Style::Alignment.new({:rotate => :poo}).rotate
|
53
54
|
end
|
54
55
|
|
55
56
|
should "set build with values correctly" do
|
@@ -59,13 +60,13 @@ module Xmlss::Style
|
|
59
60
|
:vertical => :bottom,
|
60
61
|
:rotate => 90
|
61
62
|
}
|
62
|
-
alignment = Alignment.new(attrs)
|
63
|
+
alignment = Xmlss::Style::Alignment.new(attrs)
|
63
64
|
|
64
65
|
attrs.reject{|a, v| [:horizontal, :vertical].include?(a)}.each do |a,v|
|
65
66
|
assert_equal v, alignment.send(a)
|
66
67
|
end
|
67
|
-
assert_equal Alignment.horizontal(:center), alignment.horizontal
|
68
|
-
assert_equal Alignment.vertical(:bottom), alignment.vertical
|
68
|
+
assert_equal Xmlss::Style::Alignment.horizontal(:center), alignment.horizontal
|
69
|
+
assert_equal Xmlss::Style::Alignment.vertical(:bottom), alignment.vertical
|
69
70
|
end
|
70
71
|
|
71
72
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'xmlss/style/base'
|
3
3
|
|
4
|
-
|
4
|
+
class Xmlss::Style::Base
|
5
5
|
|
6
|
-
class
|
6
|
+
class UnitTests < Assert::Context
|
7
7
|
desc "Xmlss::Style::Base"
|
8
|
-
before { @bs = Base.new(:test) }
|
8
|
+
before { @bs = Xmlss::Style::Base.new(:test) }
|
9
9
|
subject { @bs }
|
10
10
|
|
11
11
|
should have_class_method :writer
|
@@ -17,14 +17,14 @@ module Xmlss::Style
|
|
17
17
|
|
18
18
|
should "bark if you don't init with an id" do
|
19
19
|
assert_raises ArgumentError do
|
20
|
-
Base.new(nil)
|
20
|
+
Xmlss::Style::Base.new(nil)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
should "force string ids" do
|
25
|
-
assert_equal 'string', Base.new('string').id
|
26
|
-
assert_equal 'symbol', Base.new(:symbol).id
|
27
|
-
assert_equal '123',
|
25
|
+
assert_equal 'string', Xmlss::Style::Base.new('string').id
|
26
|
+
assert_equal 'symbol', Xmlss::Style::Base.new(:symbol).id
|
27
|
+
assert_equal '123', Xmlss::Style::Base.new(123).id
|
28
28
|
end
|
29
29
|
|
30
30
|
should "set it's defaults" do
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
require 'enumeration/assert_macros'
|
3
|
-
|
4
2
|
require 'xmlss/style/border'
|
5
3
|
|
6
|
-
|
7
|
-
|
4
|
+
require 'enumeration/assert_macros'
|
8
5
|
|
6
|
+
class Xmlss::Style::Border
|
9
7
|
|
10
|
-
class
|
8
|
+
class UnitTests < Assert::Context
|
11
9
|
include Enumeration::AssertMacros
|
12
10
|
|
13
11
|
desc "Xmlss::Style::Border"
|
@@ -49,8 +47,8 @@ module Xmlss::Style
|
|
49
47
|
should "set it's defaults" do
|
50
48
|
assert_equal nil, subject.color
|
51
49
|
assert_equal nil, subject.position
|
52
|
-
assert_equal Border.weight(:thin), subject.weight
|
53
|
-
assert_equal Border.line_style(:continuous), subject.line_style
|
50
|
+
assert_equal Xmlss::Style::Border.weight(:thin), subject.weight
|
51
|
+
assert_equal Xmlss::Style::Border.line_style(:continuous), subject.line_style
|
54
52
|
end
|
55
53
|
|
56
54
|
should "set attrs at init" do
|
@@ -60,14 +58,14 @@ module Xmlss::Style
|
|
60
58
|
:weight => :thick,
|
61
59
|
:line_style => :dot
|
62
60
|
}
|
63
|
-
border = Border.new(attrs)
|
61
|
+
border = Xmlss::Style::Border.new(attrs)
|
64
62
|
|
65
63
|
attrs.reject{|a, v| [:position, :weight, :line_style].include?(a)}.each do |a,v|
|
66
64
|
assert_equal v, border.send(a)
|
67
65
|
end
|
68
|
-
assert_equal Border.position(:top), border.position
|
69
|
-
assert_equal Border.weight(:thick), border.weight
|
70
|
-
assert_equal Border.line_style(:dot), border.line_style
|
66
|
+
assert_equal Xmlss::Style::Border.position(:top), border.position
|
67
|
+
assert_equal Xmlss::Style::Border.weight(:thick), border.weight
|
68
|
+
assert_equal Xmlss::Style::Border.line_style(:dot), border.line_style
|
71
69
|
end
|
72
70
|
|
73
71
|
should "set attrs by key" do
|
@@ -75,25 +73,23 @@ module Xmlss::Style
|
|
75
73
|
subject.weight = :medium
|
76
74
|
subject.line_style = :dash_dot
|
77
75
|
|
78
|
-
assert_equal Border.position(:bottom), subject.position
|
79
|
-
assert_equal Border.weight(:medium), subject.weight
|
80
|
-
assert_equal Border.line_style(:dash_dot), subject.line_style
|
76
|
+
assert_equal Xmlss::Style::Border.position(:bottom), subject.position
|
77
|
+
assert_equal Xmlss::Style::Border.weight(:medium), subject.weight
|
78
|
+
assert_equal Xmlss::Style::Border.line_style(:dash_dot), subject.line_style
|
81
79
|
end
|
82
80
|
|
83
81
|
should "set attrs by value" do
|
84
|
-
subject.position
|
85
|
-
subject.weight
|
86
|
-
subject.line_style = Border.line_style(:dash_dot)
|
82
|
+
subject.position = Xmlss::Style::Border.position(:bottom)
|
83
|
+
subject.weight = Xmlss::Style::Border.weight(:medium)
|
84
|
+
subject.line_style = Xmlss::Style::Border.line_style(:dash_dot)
|
87
85
|
|
88
|
-
assert_equal Border.position(:bottom), subject.position
|
89
|
-
assert_equal Border.weight(:medium), subject.weight
|
90
|
-
assert_equal Border.line_style(:dash_dot), subject.line_style
|
86
|
+
assert_equal Xmlss::Style::Border.position(:bottom), subject.position
|
87
|
+
assert_equal Xmlss::Style::Border.weight(:medium), subject.weight
|
88
|
+
assert_equal Xmlss::Style::Border.line_style(:dash_dot), subject.line_style
|
91
89
|
end
|
92
90
|
|
93
91
|
end
|
94
92
|
|
95
|
-
|
96
|
-
|
97
93
|
class BordersTests < Assert::Context
|
98
94
|
desc "Xmlss::Style::Borders"
|
99
95
|
before { @bs = Xmlss::Style::Borders.new }
|
@@ -107,6 +103,4 @@ module Xmlss::Style
|
|
107
103
|
|
108
104
|
end
|
109
105
|
|
110
|
-
|
111
|
-
|
112
106
|
end
|