osheet 0.7.0 → 0.8.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.
Files changed (111) hide show
  1. data/.gitignore +5 -3
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +13 -37
  4. data/Rakefile +3 -3
  5. data/lib/osheet/format/numeric.rb +0 -2
  6. data/lib/osheet/instance.rb +1 -3
  7. data/lib/osheet/version.rb +2 -2
  8. data/osheet.gemspec +3 -9
  9. data/test/cell_test.rb +96 -104
  10. data/test/column_test.rb +90 -97
  11. data/test/format/accounting_test.rb +115 -128
  12. data/test/format/currency_test.rb +115 -128
  13. data/test/format/custom_test.rb +13 -13
  14. data/test/format/datetime_test.rb +13 -13
  15. data/test/format/fraction_test.rb +63 -63
  16. data/test/format/general_test.rb +11 -11
  17. data/test/format/number_test.rb +67 -69
  18. data/test/format/percentage_test.rb +89 -91
  19. data/test/format/scientific_test.rb +89 -91
  20. data/test/format/special_test.rb +35 -35
  21. data/test/format/text_test.rb +9 -9
  22. data/test/format_test.rb +24 -24
  23. data/test/helper.rb +42 -47
  24. data/test/irb.rb +9 -0
  25. data/test/mixin_test.rb +55 -59
  26. data/test/osheet_test.rb +7 -10
  27. data/test/partial_set_test.rb +41 -61
  28. data/test/partial_test.rb +44 -46
  29. data/test/row_test.rb +92 -99
  30. data/test/style_set_test.rb +34 -37
  31. data/test/style_test.rb +72 -97
  32. data/test/template_set_test.rb +52 -73
  33. data/test/template_test.rb +31 -49
  34. data/test/workbook_test.rb +186 -199
  35. data/test/worksheet_test.rb +99 -103
  36. data/test/xmlss_writer/base_test.rb +72 -73
  37. data/test/xmlss_writer/elements_test.rb +141 -140
  38. data/test/xmlss_writer/styles_test.rb +197 -208
  39. metadata +27 -247
  40. data/.bundle/config +0 -2
  41. data/test/app_helper.rb +0 -66
  42. data/test/env.rb +0 -10
  43. data/test/rails/three/.gitignore +0 -4
  44. data/test/rails/three/Gemfile +0 -5
  45. data/test/rails/three/Gemfile.lock +0 -88
  46. data/test/rails/three/app/controllers/application_controller.rb +0 -3
  47. data/test/rails/three/app/controllers/things_controller.rb +0 -10
  48. data/test/rails/three/app/helpers/application_helper.rb +0 -2
  49. data/test/rails/three/app/views/layouts/application.html.erb +0 -14
  50. data/test/rails/three/app/views/things/index.xls.osheet +0 -13
  51. data/test/rails/three/config/application.rb +0 -42
  52. data/test/rails/three/config/boot.rb +0 -13
  53. data/test/rails/three/config/database.yml +0 -22
  54. data/test/rails/three/config/environment.rb +0 -5
  55. data/test/rails/three/config/environments/development.rb +0 -26
  56. data/test/rails/three/config/environments/production.rb +0 -49
  57. data/test/rails/three/config/environments/test.rb +0 -35
  58. data/test/rails/three/config/initializers/app.rb +0 -0
  59. data/test/rails/three/config/initializers/backtrace_silencers.rb +0 -7
  60. data/test/rails/three/config/initializers/inflections.rb +0 -10
  61. data/test/rails/three/config/initializers/mime_types.rb +0 -5
  62. data/test/rails/three/config/initializers/secret_token.rb +0 -7
  63. data/test/rails/three/config/initializers/session_store.rb +0 -8
  64. data/test/rails/three/config/locales/en.yml +0 -5
  65. data/test/rails/three/config/routes.rb +0 -3
  66. data/test/rails/three/config.ru +0 -4
  67. data/test/rails/three/db/seeds.rb +0 -7
  68. data/test/rails/three/doc/README_FOR_APP +0 -2
  69. data/test/rails/three/lib/tasks/.gitkeep +0 -0
  70. data/test/rails/three/script/rails +0 -6
  71. data/test/rails/two/.bundle/config +0 -2
  72. data/test/rails/two/Booting +0 -0
  73. data/test/rails/two/Gemfile +0 -5
  74. data/test/rails/two/Gemfile.lock +0 -45
  75. data/test/rails/two/Rails +0 -0
  76. data/test/rails/two/app/controllers/application_controller.rb +0 -20
  77. data/test/rails/two/app/controllers/things_controller.rb +0 -10
  78. data/test/rails/two/app/helpers/application_helper.rb +0 -3
  79. data/test/rails/two/app/views/things/index.xls.osheet +0 -15
  80. data/test/rails/two/config/boot.rb +0 -128
  81. data/test/rails/two/config/database.yml +0 -22
  82. data/test/rails/two/config/environment.rb +0 -41
  83. data/test/rails/two/config/environments/development.rb +0 -17
  84. data/test/rails/two/config/environments/production.rb +0 -28
  85. data/test/rails/two/config/environments/test.rb +0 -28
  86. data/test/rails/two/config/initializers/app.rb +0 -2
  87. data/test/rails/two/config/initializers/backtrace_silencers.rb +0 -7
  88. data/test/rails/two/config/initializers/cookie_verification_secret.rb +0 -7
  89. data/test/rails/two/config/initializers/inflections.rb +0 -10
  90. data/test/rails/two/config/initializers/mime_types.rb +0 -5
  91. data/test/rails/two/config/initializers/new_rails_defaults.rb +0 -21
  92. data/test/rails/two/config/initializers/session_store.rb +0 -15
  93. data/test/rails/two/config/locales/en.yml +0 -5
  94. data/test/rails/two/config/routes.rb +0 -3
  95. data/test/rails/two/db/development.sqlite3 +0 -0
  96. data/test/rails/two/db/seeds.rb +0 -7
  97. data/test/rails/two/script/about +0 -4
  98. data/test/rails/two/script/console +0 -3
  99. data/test/rails/two/script/dbconsole +0 -3
  100. data/test/rails/two/script/destroy +0 -3
  101. data/test/rails/two/script/generate +0 -3
  102. data/test/rails/two/script/performance/benchmarker +0 -3
  103. data/test/rails/two/script/performance/profiler +0 -3
  104. data/test/rails/two/script/plugin +0 -3
  105. data/test/rails/two/script/runner +0 -3
  106. data/test/rails/two/script/server +0 -3
  107. data/test/rails/two/tmp/pids/server.pid +0 -1
  108. data/test/rails_test.rb +0 -38
  109. data/test/sinatra/app.rb +0 -16
  110. data/test/sinatra/views/index.osheet +0 -13
  111. data/test/sinatra_test.rb +0 -19
@@ -3,266 +3,255 @@ require 'osheet/xmlss_writer'
3
3
 
4
4
  module Osheet
5
5
 
6
- class XmlssWriter::Style < Test::Unit::TestCase
7
- context("Xmlss style writer") do
8
-
9
- subject { XmlssWriter::Base.new }
10
- before do
11
- subject.workbook = Workbook.new {
12
- style('.font.size') { font 14 }
13
- style('.font.weight') { font :bold }
14
- style('.font.style') { font :italic }
15
- style('.align.center') { align :center }
16
- }
17
- end
18
-
19
- should "key styles based off class str and format" do
20
- assert_equal '', subject.send(:style_key, '', nil)
21
- assert_equal '.awesome', subject.send(:style_key, 'awesome', nil)
22
- assert_equal '.awesome.thing', subject.send(:style_key, 'awesome thing', nil)
23
- assert_equal '.awesome..something', subject.send(:style_key, 'awesome', 'something')
24
- assert_equal '..something', subject.send(:style_key, '', 'something')
25
- end
6
+ class XmlssWriter::StylesTest < Assert::Context
7
+ before do
8
+ @writer = XmlssWriter::Base.new
9
+ end
10
+ subject { @writer }
26
11
 
27
- should "not build a style obj when writing styles with no class str or format" do
28
- assert_equal nil, subject.send(:style, '')
29
- end
12
+ end
30
13
 
31
- should "build a style obj and add it to the writers styles" do
32
- xmlss_style = subject.send(:style, 'awesome')
33
- assert_kind_of ::Xmlss::Style::Base, xmlss_style
34
- assert_equal '.awesome', xmlss_style.id
35
- assert_equal 1, subject.styles.size
36
- assert_equal xmlss_style, subject.styles.first
37
- end
14
+ class XmlssWriter::Style < XmlssWriter::StylesTest
15
+ desc "Xmlss style writer"
16
+ before do
17
+ subject.workbook = Workbook.new {
18
+ style('.font.size') { font 14 }
19
+ style('.font.weight') { font :bold }
20
+ style('.font.style') { font :italic }
21
+ style('.align.center') { align :center }
22
+ }
23
+ end
38
24
 
39
- should "build a style obj from many matching osheet styles" do
40
- xmlss_style = subject.send(:style, 'font size weight style align center')
41
- assert_equal 14, xmlss_style.font.size
42
- assert_equal true, xmlss_style.font.bold?
43
- assert_equal true, xmlss_style.font.italic?
44
- end
25
+ should "key styles based off class str and format" do
26
+ assert_equal '', subject.send(:style_key, '', nil)
27
+ assert_equal '.awesome', subject.send(:style_key, 'awesome', nil)
28
+ assert_equal '.awesome.thing', subject.send(:style_key, 'awesome thing', nil)
29
+ assert_equal '.awesome..something', subject.send(:style_key, 'awesome', 'something')
30
+ assert_equal '..something', subject.send(:style_key, '', 'something')
31
+ end
45
32
 
46
- should "provide style ids" do
47
- assert_equal '', subject.send(:style_id, '')
48
- assert_equal '.awesome', subject.send(:style_id, 'awesome')
49
- assert_equal '..number_none_0_nocomma_black', subject.send(:style_id, '', Osheet::Format.new(:number))
50
- assert_equal 2, subject.styles.size
51
- end
33
+ should "not build a style obj when writing styles with no class str or format" do
34
+ assert_equal nil, subject.send(:style, '')
35
+ end
52
36
 
37
+ should "build a style obj and add it to the writers styles" do
38
+ xmlss_style = subject.send(:style, 'awesome')
39
+ assert_kind_of ::Xmlss::Style::Base, xmlss_style
40
+ assert_equal '.awesome', xmlss_style.id
41
+ assert_equal 1, subject.styles.size
42
+ assert_equal xmlss_style, subject.styles.first
53
43
  end
54
- end
55
44
 
56
- class XmlssWriter::Alignment < Test::Unit::TestCase
57
- context("Alignment style writer") do
58
-
59
- subject { XmlssWriter::Base.new }
60
- before do
61
- subject.workbook = Workbook.new {
62
- [
63
- :left, :center, :right,
64
- :top, :middle, :bottom,
65
- :wrap
66
- ].each do |s|
67
- style(".align.#{s}") { align s }
68
- end
69
- style('.align.rotate') { align 90 }
70
- }
71
- end
45
+ should "build a style obj from many matching osheet styles" do
46
+ xmlss_style = subject.send(:style, 'font size weight style align center')
47
+ assert_equal 14, xmlss_style.font.size
48
+ assert_equal true, xmlss_style.font.bold?
49
+ assert_equal true, xmlss_style.font.italic?
50
+ end
72
51
 
73
- should "build a style obj with empty alignment settings by default" do
74
- assert_equal nil, subject.send(:style, 'align').alignment
75
- end
52
+ should "provide style ids" do
53
+ assert_equal '', subject.send(:style_id, '')
54
+ assert_equal '.awesome', subject.send(:style_id, 'awesome')
55
+ assert_equal '..number_none_0_nocomma_black', subject.send(:style_id, '', Osheet::Format.new(:number))
56
+ assert_equal 2, subject.styles.size
57
+ end
76
58
 
77
- should "build style objs for horizontal alignment settings" do
78
- assert_equal ::Xmlss::Style::Alignment.horizontal(:left), subject.send(:style, 'align left').alignment.horizontal
79
- assert_equal ::Xmlss::Style::Alignment.horizontal(:center), subject.send(:style, 'align center').alignment.horizontal
80
- assert_equal ::Xmlss::Style::Alignment.horizontal(:right), subject.send(:style, 'align right').alignment.horizontal
81
- end
59
+ end
82
60
 
83
- should "build style objs for vertical alignment settings" do
84
- assert_equal ::Xmlss::Style::Alignment.vertical(:top), subject.send(:style, 'align top').alignment.vertical
85
- assert_equal ::Xmlss::Style::Alignment.vertical(:center), subject.send(:style, 'align middle').alignment.vertical
86
- assert_equal ::Xmlss::Style::Alignment.vertical(:bottom), subject.send(:style, 'align bottom').alignment.vertical
87
- end
61
+ class XmlssWriter::Alignment < XmlssWriter::StylesTest
62
+ desc "Alignment style writer"
63
+ before do
64
+ subject.workbook = Workbook.new {
65
+ [
66
+ :left, :center, :right,
67
+ :top, :middle, :bottom,
68
+ :wrap
69
+ ].each do |s|
70
+ style(".align.#{s}") { align s }
71
+ end
72
+ style('.align.rotate') { align 90 }
73
+ }
74
+ end
88
75
 
89
- should "build style objs for text wrap settings" do
90
- assert_equal true, subject.send(:style, 'align wrap').alignment.wrap_text?
91
- end
76
+ should "build a style obj with empty alignment settings by default" do
77
+ assert_equal nil, subject.send(:style, 'align').alignment
78
+ end
92
79
 
93
- should "build style objs for text rotation settings" do
94
- assert_equal 90, subject.send(:style, 'align rotate').alignment.rotate
95
- end
80
+ should "build style objs for horizontal alignment settings" do
81
+ assert_equal ::Xmlss::Style::Alignment.horizontal(:left), subject.send(:style, 'align left').alignment.horizontal
82
+ assert_equal ::Xmlss::Style::Alignment.horizontal(:center), subject.send(:style, 'align center').alignment.horizontal
83
+ assert_equal ::Xmlss::Style::Alignment.horizontal(:right), subject.send(:style, 'align right').alignment.horizontal
84
+ end
96
85
 
86
+ should "build style objs for vertical alignment settings" do
87
+ assert_equal ::Xmlss::Style::Alignment.vertical(:top), subject.send(:style, 'align top').alignment.vertical
88
+ assert_equal ::Xmlss::Style::Alignment.vertical(:center), subject.send(:style, 'align middle').alignment.vertical
89
+ assert_equal ::Xmlss::Style::Alignment.vertical(:bottom), subject.send(:style, 'align bottom').alignment.vertical
97
90
  end
98
- end
99
91
 
100
- class XmlssWriter::Font < Test::Unit::TestCase
101
- context("Font style writer") do
102
-
103
- subject { XmlssWriter::Base.new }
104
- before do
105
- subject.workbook = Workbook.new {
106
- [ :underline, :double_underline, :accounting_underline, :double_accounting_underline,
107
- :subscript, :superscript, :shadow, :strikethrough, :wrap,
108
- :bold, :italic
109
- ].each do |s|
110
- style(".font.#{s}") { font s }
111
- end
112
- style('.font.size') { font 14 }
113
- style('.font.color') { font '#FF0000' }
114
- }
115
- end
92
+ should "build style objs for text wrap settings" do
93
+ assert_equal true, subject.send(:style, 'align wrap').alignment.wrap_text?
94
+ end
116
95
 
117
- should "build a style obj with empty font settings by default" do
118
- assert_equal nil, subject.send(:style, 'font').font
119
- end
96
+ should "build style objs for text rotation settings" do
97
+ assert_equal 90, subject.send(:style, 'align rotate').alignment.rotate
98
+ end
120
99
 
121
- should "build style objs for font underline settings" do
122
- assert_equal ::Xmlss::Style::Font.underline(:single), subject.send(:style, 'font underline').font.underline
123
- assert_equal ::Xmlss::Style::Font.underline(:double), subject.send(:style, 'font double_underline').font.underline
124
- assert_equal ::Xmlss::Style::Font.underline(:single_accounting), subject.send(:style, 'font accounting_underline').font.underline
125
- assert_equal ::Xmlss::Style::Font.underline(:double_accounting), subject.send(:style, 'font double_accounting_underline').font.underline
126
- end
100
+ end
127
101
 
128
- should "build style objs for font alignment settings" do
129
- assert_equal ::Xmlss::Style::Font.alignment(:subscript), subject.send(:style, 'font subscript').font.alignment
130
- assert_equal ::Xmlss::Style::Font.alignment(:superscript), subject.send(:style, 'font superscript').font.alignment
131
- end
102
+ class XmlssWriter::Font < XmlssWriter::StylesTest
103
+ desc "Font style writer"
104
+ before do
105
+ subject.workbook = Workbook.new {
106
+ [ :underline, :double_underline, :accounting_underline, :double_accounting_underline,
107
+ :subscript, :superscript, :shadow, :strikethrough, :wrap,
108
+ :bold, :italic
109
+ ].each do |s|
110
+ style(".font.#{s}") { font s }
111
+ end
112
+ style('.font.size') { font 14 }
113
+ style('.font.color') { font '#FF0000' }
114
+ }
115
+ end
132
116
 
133
- should "build style objs for font style settings" do
134
- assert_equal true, subject.send(:style, 'font bold').font.bold?
135
- assert_equal true, subject.send(:style, 'font italic').font.italic?
136
- assert_equal true, subject.send(:style, 'font strikethrough').font.strike_through?
137
- assert_equal true, subject.send(:style, 'font shadow').font.shadow?
138
- end
117
+ should "build a style obj with empty font settings by default" do
118
+ assert_equal nil, subject.send(:style, 'font').font
119
+ end
139
120
 
140
- should "build style objs for font size" do
141
- assert_equal 14, subject.send(:style, 'font size').font.size
142
- end
121
+ should "build style objs for font underline settings" do
122
+ assert_equal ::Xmlss::Style::Font.underline(:single), subject.send(:style, 'font underline').font.underline
123
+ assert_equal ::Xmlss::Style::Font.underline(:double), subject.send(:style, 'font double_underline').font.underline
124
+ assert_equal ::Xmlss::Style::Font.underline(:single_accounting), subject.send(:style, 'font accounting_underline').font.underline
125
+ assert_equal ::Xmlss::Style::Font.underline(:double_accounting), subject.send(:style, 'font double_accounting_underline').font.underline
126
+ end
143
127
 
144
- should "build style objs for font color" do
145
- assert_equal '#FF0000', subject.send(:style, 'font color').font.color
146
- end
128
+ should "build style objs for font alignment settings" do
129
+ assert_equal ::Xmlss::Style::Font.alignment(:subscript), subject.send(:style, 'font subscript').font.alignment
130
+ assert_equal ::Xmlss::Style::Font.alignment(:superscript), subject.send(:style, 'font superscript').font.alignment
131
+ end
147
132
 
133
+ should "build style objs for font style settings" do
134
+ assert_equal true, subject.send(:style, 'font bold').font.bold?
135
+ assert_equal true, subject.send(:style, 'font italic').font.italic?
136
+ assert_equal true, subject.send(:style, 'font strikethrough').font.strike_through?
137
+ assert_equal true, subject.send(:style, 'font shadow').font.shadow?
148
138
  end
149
- end
150
139
 
151
- class XmlssWriter::Bg < Test::Unit::TestCase
152
- context("Bg writer") do
153
-
154
- subject { XmlssWriter::Base.new }
155
- before do
156
- subject.workbook = Workbook.new {
157
- style('.bg.color') { bg '#FF0000' }
158
- style('.bg.pattern-only') { bg :solid }
159
- style('.bg.pattern-color') { bg :horz_stripe => '#0000FF' }
160
- style('.bg.color-first') { bg '#00FF00', {:horz_stripe => '#0000FF'} }
161
- style('.bg.pattern-first') { bg({:horz_stripe => '#0000FF'}, '#00FF00') }
162
- }
163
- end
140
+ should "build style objs for font size" do
141
+ assert_equal 14, subject.send(:style, 'font size').font.size
142
+ end
164
143
 
165
- should "build a style obj with empty bg settings by default" do
166
- assert_equal nil, subject.send(:style, 'bg').interior
167
- end
144
+ should "build style objs for font color" do
145
+ assert_equal '#FF0000', subject.send(:style, 'font color').font.color
146
+ end
168
147
 
169
- should "build style objs for bg color and auto set the pattern to solid" do
170
- assert_equal '#FF0000', subject.send(:style, 'bg color').interior.color
171
- end
148
+ end
172
149
 
173
- should "build style objs for bg pattern settings" do
174
- assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg pattern-only').interior.pattern
175
- assert_equal nil, subject.send(:style, 'bg pattern-only').interior.pattern_color
176
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-color').interior.pattern
177
- assert_equal '#0000FF', subject.send(:style, 'bg pattern-color').interior.pattern_color
178
- end
150
+ class XmlssWriter::Bg < XmlssWriter::StylesTest
151
+ desc "Bg writer"
152
+ before do
153
+ subject.workbook = Workbook.new {
154
+ style('.bg.color') { bg '#FF0000' }
155
+ style('.bg.pattern-only') { bg :solid }
156
+ style('.bg.pattern-color') { bg :horz_stripe => '#0000FF' }
157
+ style('.bg.color-first') { bg '#00FF00', {:horz_stripe => '#0000FF'} }
158
+ style('.bg.pattern-first') { bg({:horz_stripe => '#0000FF'}, '#00FF00') }
159
+ }
160
+ end
179
161
 
180
- should "set pattern to solid when setting bg color" do
181
- assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg color').interior.pattern
182
- end
162
+ should "build a style obj with empty bg settings by default" do
163
+ assert_equal nil, subject.send(:style, 'bg').interior
164
+ end
183
165
 
184
- should "set pattern to pattern setting when first setting bg color then pattern" do
185
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg color-first').interior.pattern
186
- end
166
+ should "build style objs for bg color and auto set the pattern to solid" do
167
+ assert_equal '#FF0000', subject.send(:style, 'bg color').interior.color
168
+ end
187
169
 
188
- should "set pattern to pattern setting when first setting bg pattern then color" do
189
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-first').interior.pattern
190
- end
170
+ should "build style objs for bg pattern settings" do
171
+ assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg pattern-only').interior.pattern
172
+ assert_equal nil, subject.send(:style, 'bg pattern-only').interior.pattern_color
173
+ assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-color').interior.pattern
174
+ assert_equal '#0000FF', subject.send(:style, 'bg pattern-color').interior.pattern_color
175
+ end
191
176
 
177
+ should "set pattern to solid when setting bg color" do
178
+ assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg color').interior.pattern
192
179
  end
193
- end
194
180
 
195
- class XmlssWriter::Border < Test::Unit::TestCase
196
- context("Font border writer") do
197
-
198
- subject { XmlssWriter::Base.new }
199
- before do
200
- subject.workbook = Workbook.new {
201
- ::Osheet::Style::BORDER_POSITIONS.each do |p|
202
- style(".border.#{p}") { send("border_#{p}", :thin) }
203
- end
204
- [:hairline, :thin, :medium, :thick].each do |w|
205
- style(".border.#{w}") { border_top w }
206
- end
207
- [:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
208
- style(".border.#{s}") { border_top s }
209
- end
210
- style('.border.color') { border_top '#FF0000' }
211
- style('.border.all') { border :thick, :dash, '#FF0000' }
212
- }
213
- end
181
+ should "set pattern to pattern setting when first setting bg color then pattern" do
182
+ assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg color-first').interior.pattern
183
+ end
214
184
 
215
- should "build a style obj with empty border settings by default" do
216
- style = subject.send(:style, 'border')
217
- assert_kind_of ::Xmlss::ItemSet, style.borders
218
- assert_equal [], style.borders
219
- end
185
+ should "set pattern to pattern setting when first setting bg pattern then color" do
186
+ assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-first').interior.pattern
187
+ end
220
188
 
221
- should "build style objs with identical settings for all positions when using 'border'" do
222
- style = subject.send(:style, 'border all')
223
- assert_equal 4, style.borders.size
224
- assert_equal 1, style.borders.collect{|p| p.weight}.uniq.size
225
- assert_equal 1, style.borders.collect{|p| p.line_style}.uniq.size
226
- assert_equal 1, style.borders.collect{|p| p.color}.uniq.size
227
- end
189
+ end
228
190
 
229
- should "build style objs for border specific positions" do
191
+ class XmlssWriter::Border < XmlssWriter::StylesTest
192
+ desc "Font border writer"
193
+ before do
194
+ subject.workbook = Workbook.new {
230
195
  ::Osheet::Style::BORDER_POSITIONS.each do |p|
231
- assert_equal ::Xmlss::Style::Border.position(p), subject.send(:style, "border #{p}").borders.first.position
196
+ style(".border.#{p}") { send("border_#{p}", :thin) }
232
197
  end
233
- end
234
-
235
- should "build style objs for border weight settings" do
236
198
  [:hairline, :thin, :medium, :thick].each do |w|
237
- assert_equal ::Xmlss::Style::Border.weight(w), subject.send(:style, "border #{w}").borders.first.weight
199
+ style(".border.#{w}") { border_top w }
238
200
  end
239
- end
240
-
241
- should "build style objs for border style settings" do
242
201
  [:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
243
- assert_equal ::Xmlss::Style::Border.line_style(s), subject.send(:style, "border #{s}").borders.first.line_style
202
+ style(".border.#{s}") { border_top s }
244
203
  end
245
- end
204
+ style('.border.color') { border_top '#FF0000' }
205
+ style('.border.all') { border :thick, :dash, '#FF0000' }
206
+ }
207
+ end
246
208
 
247
- should "build style objs for border color" do
248
- assert_equal '#FF0000', subject.send(:style, 'border color').borders.first.color
249
- end
209
+ should "build a style obj with empty border settings by default" do
210
+ style = subject.send(:style, 'border')
211
+ assert_kind_of ::Xmlss::ItemSet, style.borders
212
+ assert_equal [], style.borders
213
+ end
250
214
 
215
+ should "build style objs with identical settings for all positions when using 'border'" do
216
+ style = subject.send(:style, 'border all')
217
+ assert_equal 4, style.borders.size
218
+ assert_equal 1, style.borders.collect{|p| p.weight}.uniq.size
219
+ assert_equal 1, style.borders.collect{|p| p.line_style}.uniq.size
220
+ assert_equal 1, style.borders.collect{|p| p.color}.uniq.size
251
221
  end
252
- end
253
222
 
254
- class XmlssWriter::NumberFormat < Test::Unit::TestCase
255
- context("Xmlss style number format writer") do
223
+ should "build style objs for border specific positions" do
224
+ ::Osheet::Style::BORDER_POSITIONS.each do |p|
225
+ assert_equal ::Xmlss::Style::Border.position(p), subject.send(:style, "border #{p}").borders.first.position
226
+ end
227
+ end
256
228
 
257
- subject { XmlssWriter::Base.new }
229
+ should "build style objs for border weight settings" do
230
+ [:hairline, :thin, :medium, :thick].each do |w|
231
+ assert_equal ::Xmlss::Style::Border.weight(w), subject.send(:style, "border #{w}").borders.first.weight
232
+ end
233
+ end
258
234
 
259
- should "build a style obj with formatting" do
260
- assert_equal '@', subject.send(:style, '', Osheet::Format.new(:text)).number_format.format
261
- assert_equal 'mm/dd/yy', subject.send(:style, '', Osheet::Format.new(:datetime, 'mm/dd/yy')).number_format.format
235
+ should "build style objs for border style settings" do
236
+ [:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
237
+ assert_equal ::Xmlss::Style::Border.line_style(s), subject.send(:style, "border #{s}").borders.first.line_style
262
238
  end
239
+ end
263
240
 
241
+ should "build style objs for border color" do
242
+ assert_equal '#FF0000', subject.send(:style, 'border color').borders.first.color
264
243
  end
244
+
265
245
  end
266
246
 
247
+ class XmlssWriter::NumberFormat < XmlssWriter::StylesTest
248
+ desc "Xmlss style number format writer"
249
+
250
+ should "build a style obj with formatting" do
251
+ assert_equal '@', subject.send(:style, '', Osheet::Format.new(:text)).number_format.format
252
+ assert_equal 'mm/dd/yy', subject.send(:style, '', Osheet::Format.new(:datetime, 'mm/dd/yy')).number_format.format
253
+ end
254
+
255
+ end
267
256
 
268
257
  end