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
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
- /pkg/
2
- /doc/
3
- /coverage/
1
+ pkg/*
2
+ .bundle
3
+ *.gem
4
4
  *.log
5
+ .rvmrc
6
+ .rbenv-version
5
7
  /tmp
6
8
  /examples/*.xls
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in osheet.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake', '~>0.9.2'
data/Gemfile.lock CHANGED
@@ -1,52 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osheet (0.7.0)
5
- enumeration (~> 1.1.0)
6
- xmlss (~> 0.2.0)
4
+ osheet (0.8.0)
5
+ enumeration (~> 1.2)
6
+ xmlss (~> 0.2)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- enumeration (1.1.0)
12
- json (1.5.1)
13
- kelredd-useful (0.4.1)
14
- json
15
- leftright (0.9.0)
16
- mime-types (1.16)
17
- nokogiri (1.4.4)
18
- open4 (1.0.1)
19
- rack (1.2.2)
20
- rack-test (0.5.7)
21
- rack (>= 1.0)
22
- rest-client (1.6.1)
23
- mime-types (>= 1.16)
24
- shoulda (2.11.3)
25
- sinatra (1.2.1)
26
- rack (~> 1.1)
27
- tilt (>= 1.2.2, < 2.0)
28
- test-belt (0.2.1)
29
- kelredd-useful (~> 0.4.0)
30
- leftright (~> 0.9.0)
31
- shoulda (~> 2.11)
32
- tilt (1.2.2)
33
- webrat (0.7.3)
34
- nokogiri (>= 1.2.0)
35
- rack (>= 1.0)
36
- rack-test (>= 0.5.3)
37
- xmlss (0.2.0)
38
- enumeration (~> 1.1.0)
11
+ ansi (1.3.0)
12
+ assert (0.3.0)
13
+ ansi (~> 1.3)
14
+ enumeration (1.2.1)
15
+ nokogiri (1.4.7)
16
+ rake (0.9.2)
17
+ xmlss (0.2.1)
18
+ enumeration (~> 1.2)
39
19
  nokogiri (~> 1.4.0)
40
20
 
41
21
  PLATFORMS
42
22
  ruby
43
23
 
44
24
  DEPENDENCIES
25
+ assert (~> 0.3)
45
26
  bundler (~> 1.0)
46
- open4
47
27
  osheet!
48
- rack-test (>= 0.5.3)
49
- rest-client
50
- sinatra (>= 0.9.4)
51
- test-belt (= 0.2.1)
52
- webrat (>= 0.6.0)
28
+ rake (~> 0.9.2)
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
+ require 'assert/rake_tasks'
2
+ include Assert::RakeTasks
3
+
1
4
  require 'bundler'
2
5
  Bundler::GemHelper.install_tasks
3
6
 
4
- require 'test_belt/rake_tasks'
5
- TestBelt::RakeTasks.for :test
6
-
7
7
  task :default => :build
@@ -99,8 +99,6 @@ module Osheet::Format
99
99
  case @symbol
100
100
  when :dollar
101
101
  "\"$\"#{symbol_suffix}"
102
- when :euro
103
- "[$€-2]\ #{symbol_suffix}"
104
102
  when :none
105
103
  ''
106
104
  end
@@ -24,9 +24,7 @@ module Osheet::Instance
24
24
  binding.eval('instance_variables').
25
25
  reject{|ivar| ivar =~ /^@#{OSHEET_IVAR_NS}/}.
26
26
  each do |ivar|
27
- # puts "binding #{ivar}: "+binding.eval(ivar).object_id.to_s
28
- instance_variable_set(ivar, binding.eval(ivar))
29
- # puts "inst #{ivar}: "+ instance_variable_get(ivar).object_id.to_s
27
+ instance_variable_set(ivar, binding.eval(ivar.to_s))
30
28
  end
31
29
  end
32
30
  end
@@ -1,3 +1,3 @@
1
1
  module Osheet
2
- VERSION = "0.7.0"
3
- end
2
+ VERSION = "0.8.0"
3
+ end
data/osheet.gemspec CHANGED
@@ -18,14 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_development_dependency("bundler", ["~> 1.0"])
21
- s.add_development_dependency("test-belt", ["= 0.2.1"]) # locked to a specific version for test stability
22
- s.add_development_dependency("sinatra", [">= 0.9.4"])
23
- s.add_development_dependency("rack-test", [">= 0.5.3"])
24
- s.add_development_dependency("webrat", [">= 0.6.0"])
25
- s.add_development_dependency("open4")
26
- s.add_development_dependency("rest-client")
27
-
28
- s.add_dependency("enumeration", ["~>1.1.0"])
29
- s.add_dependency("xmlss", "~>0.2.0")
21
+ s.add_development_dependency("assert", ["~> 0.3"])
22
+ s.add_dependency("enumeration", ["~> 1.2"])
23
+ s.add_dependency("xmlss", ["~> 0.2"])
30
24
 
31
25
  end
data/test/cell_test.rb CHANGED
@@ -1,138 +1,130 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/cell'
3
3
 
4
4
  module Osheet
5
5
 
6
- class CellTest < Test::Unit::TestCase
7
- context "Osheet::Cell" do
8
- subject { Cell.new }
6
+ class CellTest < Assert::Context
7
+ desc "Osheet::Cell"
8
+ before { @c = Cell.new }
9
+ subject { @c }
9
10
 
10
- should_be_a_styled_element(Cell)
11
- should_be_a_worksheet_element(Cell)
12
- should_be_a_workbook_element(Cell)
11
+ should_be_a_styled_element(Cell)
12
+ should_be_a_worksheet_element(Cell)
13
+ should_be_a_workbook_element(Cell)
13
14
 
14
- should_have_instance_methods :data, :format, :colspan, :rowspan, :href, :index
15
-
16
- should "set it's defaults" do
17
- assert_equal nil, subject.send(:get_ivar, "data")
18
- assert_kind_of Format::General, subject.send(:get_ivar, "format")
19
- assert_equal 1, subject.send(:get_ivar, "colspan")
20
- assert_equal 1, subject.send(:get_ivar, "rowspan")
21
- assert_equal nil, subject.send(:get_ivar, "href")
22
- assert_equal nil, subject.send(:get_ivar, "index")
23
- end
15
+ should have_instance_methods :data, :format, :colspan, :rowspan, :href, :index
24
16
 
17
+ should "set it's defaults" do
18
+ assert_equal nil, subject.send(:get_ivar, "data")
19
+ assert_kind_of Format::General, subject.send(:get_ivar, "format")
20
+ assert_equal 1, subject.send(:get_ivar, "colspan")
21
+ assert_equal 1, subject.send(:get_ivar, "rowspan")
22
+ assert_equal nil, subject.send(:get_ivar, "href")
23
+ assert_equal nil, subject.send(:get_ivar, "index")
25
24
  end
26
- end
27
25
 
28
- class CellAttributeTest < Test::Unit::TestCase
29
- context "a celll that has attributes" do
30
- subject do
31
- Cell.new do
32
- style_class 'more poo'
33
- data "Poo"
34
- format :number
35
- colspan 4
36
- rowspan 2
37
- index 3
38
- href "http://www.google.com"
39
- end
26
+ should "type cast data strings/symbols" do
27
+ ['a string', :symbol].each do |thing|
28
+ cell = Cell.new{data thing}
29
+ assert_kind_of ::String, cell.send(:get_ivar, "data")
40
30
  end
31
+ end
41
32
 
42
- should "should set them correctly" do
43
- assert_equal "Poo", subject.send(:get_ivar, "data")
44
- assert_kind_of Format::Number, subject.send(:get_ivar, "format")
45
- assert_equal 4, subject.send(:get_ivar, "colspan")
46
- assert_equal 2, subject.send(:get_ivar, "rowspan")
47
- assert_equal 3, subject.send(:get_ivar, "index")
48
- assert_equal "http://www.google.com", subject.send(:get_ivar, "href")
49
- end
33
+ should "type cast data dates" do
34
+ cell = Cell.new{data Date.today}
35
+ assert_kind_of ::Date, cell.send(:get_ivar, "data")
36
+ end
50
37
 
51
- should "know it's attribute(s)" do
52
- [:style_class, :data, :format, :rowspan, :colspan, :index, :href].each do |a|
53
- assert subject.attributes.has_key?(a)
54
- end
55
-
56
- assert_equal "more poo", subject.attributes[:style_class]
57
- assert_equal "Poo", subject.attributes[:data]
58
- assert_kind_of Format::Number, subject.attributes[:format]
59
- assert_equal 4, subject.attributes[:colspan]
60
- assert_equal 2, subject.attributes[:rowspan]
61
- assert_equal 3, subject.attributes[:index]
62
- assert_equal "http://www.google.com", subject.attributes[:href]
38
+ should "type cast data numerics" do
39
+ [1, 1.0].each do |thing|
40
+ cell = Cell.new{data thing}
41
+ assert_kind_of ::Numeric, cell.send(:get_ivar, "data")
63
42
  end
64
-
65
43
  end
66
- end
67
-
68
- class CellDataTest < Test::Unit::TestCase
69
- context "A cell" do
70
- subject { Cell.new }
71
44
 
72
- should "type cast data strings/symbols" do
73
- ['a string', :symbol].each do |thing|
74
- cell = Cell.new{data thing}
75
- assert_kind_of ::String, cell.send(:get_ivar, "data")
76
- end
45
+ should "type cast all other data to string" do
46
+ [Osheet, [:a, 'Aye'], {:a => 'Aye'}].each do |thing|
47
+ cell = Cell.new{data thing}
48
+ assert_kind_of ::String, cell.send(:get_ivar, "data")
77
49
  end
50
+ end
78
51
 
79
- should "type cast data dates" do
80
- cell = Cell.new{data Date.today}
81
- assert_kind_of ::Date, cell.send(:get_ivar, "data")
82
- end
52
+ end
83
53
 
84
- should "type cast data numerics" do
85
- [1, 1.0].each do |thing|
86
- cell = Cell.new{data thing}
87
- assert_kind_of ::Numeric, cell.send(:get_ivar, "data")
88
- end
54
+ class CellAttributeTest < CellTest
55
+ desc "a celll that has attributes"
56
+ before do
57
+ @c = Cell.new do
58
+ style_class 'more poo'
59
+ data "Poo"
60
+ format :number
61
+ colspan 4
62
+ rowspan 2
63
+ index 3
64
+ href "http://www.google.com"
89
65
  end
66
+ end
67
+
68
+ should "should set them correctly" do
69
+ assert_equal "Poo", subject.send(:get_ivar, "data")
70
+ assert_kind_of Format::Number, subject.send(:get_ivar, "format")
71
+ assert_equal 4, subject.send(:get_ivar, "colspan")
72
+ assert_equal 2, subject.send(:get_ivar, "rowspan")
73
+ assert_equal 3, subject.send(:get_ivar, "index")
74
+ assert_equal "http://www.google.com", subject.send(:get_ivar, "href")
75
+ end
90
76
 
91
- should "type cast all other data to string" do
92
- [Osheet, [:a, 'Aye'], {:a => 'Aye'}].each do |thing|
93
- cell = Cell.new{data thing}
94
- assert_kind_of ::String, cell.send(:get_ivar, "data")
95
- end
77
+ should "know it's attribute(s)" do
78
+ [:style_class, :data, :format, :rowspan, :colspan, :index, :href].each do |a|
79
+ assert subject.attributes.has_key?(a)
96
80
  end
97
81
 
82
+ assert_equal "more poo", subject.attributes[:style_class]
83
+ assert_equal "Poo", subject.attributes[:data]
84
+ assert_kind_of Format::Number, subject.attributes[:format]
85
+ assert_equal 4, subject.attributes[:colspan]
86
+ assert_equal 2, subject.attributes[:rowspan]
87
+ assert_equal 3, subject.attributes[:index]
88
+ assert_equal "http://www.google.com", subject.attributes[:href]
98
89
  end
90
+
99
91
  end
100
92
 
101
- class CellPartialTest < Test::Unit::TestCase
102
- context "A workbook that defines column partials" do
103
- subject do
104
- Workbook.new {
105
- partial(:cell_stuff) {
106
- style_class 'more poo'
107
- data "Poo"
108
- }
109
-
110
- worksheet { row { cell {
111
- add :cell_stuff
112
- } } }
93
+ class CellPartialTest < Assert::Context
94
+ desc "A workbook that defines column partials"
95
+ before do
96
+ @wkbk = Workbook.new {
97
+ partial(:cell_stuff) {
98
+ style_class 'more poo'
99
+ data "Poo"
113
100
  }
114
- end
115
101
 
116
- should "add it's partials to it's markup" do
117
- assert_equal 'more poo', subject.worksheets.first.rows.first.cells.first.attributes[:style_class]
118
- assert_equal 'Poo', subject.worksheets.first.rows.first.cells.first.attributes[:data]
119
- end
102
+ worksheet { row { cell {
103
+ add :cell_stuff
104
+ } } }
105
+ }
106
+ end
107
+ subject { @wkbk }
120
108
 
109
+ should "add it's partials to it's markup" do
110
+ assert_equal 'more poo', subject.worksheets.first.rows.first.cells.first.attributes[:style_class]
111
+ assert_equal 'Poo', subject.worksheets.first.rows.first.cells.first.attributes[:data]
121
112
  end
113
+
122
114
  end
123
115
 
124
- class CellBindingTest < Test::Unit::TestCase
125
- context "a cell defined w/ a block" do
126
- should "access instance vars from that block's binding" do
127
- @test = 'test'
128
- @cell = Cell.new { data @test}
129
-
130
- assert !@cell.send(:instance_variable_get, "@test").nil?
131
- assert_equal @test, @cell.send(:instance_variable_get, "@test")
132
- assert_equal @test.object_id, @cell.send(:instance_variable_get, "@test").object_id
133
- assert_equal @test, @cell.attributes[:data]
134
- assert_equal @test.object_id, @cell.attributes[:data].object_id
135
- end
116
+ class CellBindingTest < Assert::Context
117
+ desc "a cell defined w/ a block"
118
+
119
+ should "access instance vars from that block's binding" do
120
+ @test = 'test'
121
+ @cell = Cell.new { data @test}
122
+
123
+ assert !@cell.send(:instance_variable_get, "@test").nil?
124
+ assert_equal @test, @cell.send(:instance_variable_get, "@test")
125
+ assert_equal @test.object_id, @cell.send(:instance_variable_get, "@test").object_id
126
+ assert_equal @test, @cell.attributes[:data]
127
+ assert_equal @test.object_id, @cell.attributes[:data].object_id
136
128
  end
137
129
  end
138
130
 
data/test/column_test.rb CHANGED
@@ -1,128 +1,121 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require "osheet/column"
3
3
 
4
4
  module Osheet
5
5
 
6
- class ColumnTest < Test::Unit::TestCase
7
- context "Osheet::Column" do
8
- subject { Column.new }
6
+ class ColumnTest < Assert::Context
7
+ desc "Osheet::Column"
8
+ before { @c = Column.new }
9
+ subject { @c }
9
10
 
10
- should_be_a_styled_element(Column)
11
- should_be_a_worksheet_element(Column)
12
- should_be_a_workbook_element(Column)
11
+ should_be_a_styled_element(Column)
12
+ should_be_a_worksheet_element(Column)
13
+ should_be_a_workbook_element(Column)
13
14
 
14
- should_have_instance_method :width
15
- should_have_instance_methods :autofit, :autofit?
16
- should_have_instance_methods :hidden, :hidden?
17
- should_have_instance_method :meta
15
+ should have_instance_method :width
16
+ should have_instance_methods :autofit, :autofit?
17
+ should have_instance_methods :hidden, :hidden?
18
+ should have_instance_method :meta
18
19
 
19
- should "set it's defaults" do
20
- assert_equal nil, subject.send(:get_ivar, "width")
21
- assert_equal false, subject.send(:get_ivar, "autofit")
22
- assert !subject.autofit?
23
- assert_equal false, subject.send(:get_ivar, "hidden")
24
- assert !subject.hidden?
20
+ should "set it's defaults" do
21
+ assert_equal nil, subject.send(:get_ivar, "width")
22
+ assert_equal false, subject.send(:get_ivar, "autofit")
23
+ assert !subject.autofit?
24
+ assert_equal false, subject.send(:get_ivar, "hidden")
25
+ assert !subject.hidden?
25
26
 
26
- assert_equal nil, subject.meta
27
- end
27
+ assert_equal nil, subject.meta
28
+ end
28
29
 
30
+ should "set it's width" do
31
+ subject.width(false)
32
+ assert_equal false, subject.width
33
+ subject.width(180)
34
+ assert_equal 180, subject.width
35
+ subject.width(nil)
36
+ assert_equal 180, subject.width
29
37
  end
30
- end
31
38
 
32
- class ColumnAttributesTest < Test::Unit::TestCase
33
- context "that has attributes" do
34
- subject do
35
- Column.new do
36
- style_class "more poo"
37
- width 100
38
- autofit true
39
- hidden true
40
- meta(
41
- {}
42
- )
43
- end
44
- end
39
+ should "cast autofit and hidden to bool" do
40
+ col = Column.new { autofit :true; hidden 'false'}
41
+ assert_kind_of ::TrueClass, col.send(:get_ivar, "autofit")
42
+ assert_kind_of ::TrueClass, col.send(:get_ivar, "hidden")
43
+ end
45
44
 
46
- should "should set them correctly" do
47
- assert_equal 100, subject.send(:get_ivar, "width")
48
- assert_equal true, subject.send(:get_ivar, "autofit")
49
- assert subject.autofit?
50
- assert_equal true, subject.send(:get_ivar, "hidden")
51
- assert subject.hidden?
52
- assert_equal({}, subject.meta)
53
- end
45
+ end
54
46
 
55
- should "know it's attribute(s)" do
56
- [:style_class, :width, :autofit, :hidden].each do |a|
57
- assert subject.attributes.has_key?(a)
58
- end
59
- assert_equal 'more poo', subject.attributes[:style_class]
60
- assert_equal 100, subject.attributes[:width]
61
- assert_equal true, subject.attributes[:autofit]
62
- assert_equal true, subject.attributes[:hidden]
47
+ class ColumnAttributesTest < ColumnTest
48
+ desc "that has attributes"
49
+ before do
50
+ @c = Column.new do
51
+ style_class "more poo"
52
+ width 100
53
+ autofit true
54
+ hidden true
55
+ meta(
56
+ {}
57
+ )
63
58
  end
64
-
65
59
  end
66
- end
67
60
 
68
- class ColumnDataTest < Test::Unit::TestCase
69
- context "A column" do
70
- subject { Column.new }
71
-
72
- should "set it's width" do
73
- subject.width(false)
74
- assert_equal false, subject.width
75
- subject.width(180)
76
- assert_equal 180, subject.width
77
- subject.width(nil)
78
- assert_equal 180, subject.width
79
- end
61
+ should "should set them correctly" do
62
+ assert_equal 100, subject.send(:get_ivar, "width")
63
+ assert_equal true, subject.send(:get_ivar, "autofit")
64
+ assert subject.autofit?
65
+ assert_equal true, subject.send(:get_ivar, "hidden")
66
+ assert subject.hidden?
67
+ assert_equal({}, subject.meta)
68
+ end
80
69
 
81
- should "cast autofit and hidden to bool" do
82
- col = Column.new { autofit :true; hidden 'false'}
83
- assert_kind_of ::TrueClass, col.send(:get_ivar, "autofit")
84
- assert_kind_of ::TrueClass, col.send(:get_ivar, "hidden")
70
+ should "know it's attribute(s)" do
71
+ [:style_class, :width, :autofit, :hidden].each do |a|
72
+ assert subject.attributes.has_key?(a)
85
73
  end
86
-
74
+ assert_equal 'more poo', subject.attributes[:style_class]
75
+ assert_equal 100, subject.attributes[:width]
76
+ assert_equal true, subject.attributes[:autofit]
77
+ assert_equal true, subject.attributes[:hidden]
87
78
  end
79
+
88
80
  end
89
81
 
90
- class ColumnPartialTest < Test::Unit::TestCase
91
- context "A workbook that defines column partials" do
92
- subject do
93
- Workbook.new {
94
- partial(:column_stuff) {
95
- width 200
96
- meta(:label => 'awesome')
97
- }
98
-
99
- worksheet { column {
100
- add :column_stuff
101
- } }
82
+ class ColumnPartialTest < Assert::Context
83
+ desc "A workbook that defines column partials"
84
+ before do
85
+ @wkbk = Workbook.new {
86
+ partial(:column_stuff) {
87
+ width 200
88
+ meta(:label => 'awesome')
102
89
  }
103
- end
104
90
 
105
- should "add it's partials to it's markup" do
106
- assert_equal 200, subject.worksheets.first.columns.first.width
107
- assert_equal({:label => 'awesome'}, subject.worksheets.first.columns.first.meta)
108
- end
91
+ worksheet { column {
92
+ add :column_stuff
93
+ } }
94
+ }
95
+ end
96
+ subject { @wkbk }
109
97
 
98
+ should "add it's partials to it's markup" do
99
+ assert_equal 200, subject.worksheets.first.columns.first.width
100
+ assert_equal({:label => 'awesome'}, subject.worksheets.first.columns.first.meta)
110
101
  end
102
+
111
103
  end
112
104
 
113
- class ColumnBindingTest < Test::Unit::TestCase
114
- context "a column defined w/ a block" do
115
- should "access instance vars from that block's binding" do
116
- @test = 50
117
- @col = Column.new { width @test }
118
-
119
- assert !@col.send(:instance_variable_get, "@test").nil?
120
- assert_equal @test, @col.send(:instance_variable_get, "@test")
121
- assert_equal @test.object_id, @col.send(:instance_variable_get, "@test").object_id
122
- assert_equal @test, @col.attributes[:width]
123
- assert_equal @test.object_id, @col.attributes[:width].object_id
124
- end
105
+ class ColumnBindingTest < Assert::Context
106
+ desc "a column defined w/ a block"
107
+
108
+ should "access instance vars from that block's binding" do
109
+ @test = 50
110
+ @col = Column.new { width @test }
111
+
112
+ assert !@col.send(:instance_variable_get, "@test").nil?
113
+ assert_equal @test, @col.send(:instance_variable_get, "@test")
114
+ assert_equal @test.object_id, @col.send(:instance_variable_get, "@test").object_id
115
+ assert_equal @test, @col.attributes[:width]
116
+ assert_equal @test.object_id, @col.attributes[:width].object_id
125
117
  end
118
+
126
119
  end
127
120
 
128
121
  end