osheet 0.10.0 → 1.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/Gemfile +0 -1
  2. data/Gemfile.lock +9 -6
  3. data/Rakefile +35 -19
  4. data/bench/bench_runner.rb +91 -0
  5. data/bench/profiler_runner.rb +1 -0
  6. data/examples/basic.rb +1 -1
  7. data/examples/basic.xls +2 -1
  8. data/examples/basic_with_templates.rb +2 -2
  9. data/examples/basic_with_templates.xls +3 -3
  10. data/examples/formats.rb +2 -2
  11. data/examples/formats.xls +46 -46
  12. data/examples/formula.rb +2 -2
  13. data/examples/styles.rb +2 -2
  14. data/examples/styles.xls +5 -5
  15. data/examples/trivial.rb +2 -2
  16. data/lib/osheet/cell.rb +48 -46
  17. data/lib/osheet/column.rb +23 -29
  18. data/lib/osheet/format.rb +3 -3
  19. data/lib/osheet/meta_element.rb +2 -1
  20. data/lib/osheet/mixin.rb +21 -9
  21. data/lib/osheet/partial.rb +5 -9
  22. data/lib/osheet/row.rb +28 -32
  23. data/lib/osheet/style.rb +11 -25
  24. data/lib/osheet/styled_element.rb +9 -1
  25. data/lib/osheet/template.rb +3 -8
  26. data/lib/osheet/version.rb +1 -1
  27. data/lib/osheet/workbook.rb +135 -43
  28. data/lib/osheet/workbook_api.rb +208 -0
  29. data/lib/osheet/workbook_element.rb +225 -8
  30. data/lib/osheet/worksheet.rb +22 -28
  31. data/lib/osheet/xmlss_writer/style_cache.rb +64 -0
  32. data/lib/osheet/xmlss_writer/style_settings.rb +148 -0
  33. data/lib/osheet/xmlss_writer.rb +143 -1
  34. data/lib/osheet.rb +3 -29
  35. data/osheet.gemspec +4 -1
  36. data/test/cell_test.rb +33 -98
  37. data/test/column_test.rb +20 -88
  38. data/test/{mixins.rb → fixtures/mixins.rb} +6 -4
  39. data/test/fixtures/test_writer.rb +68 -0
  40. data/test/format_test.rb +2 -2
  41. data/test/helper.rb +34 -68
  42. data/test/mixin_test.rb +37 -43
  43. data/test/partial_test.rb +3 -26
  44. data/test/row_test.rb +32 -85
  45. data/test/style_test.rb +9 -26
  46. data/test/template_test.rb +5 -6
  47. data/test/workbook_element_test.rb +231 -0
  48. data/test/workbook_test.rb +225 -116
  49. data/test/worksheet_test.rb +51 -98
  50. data/test/xmlss_writer/api_test.rb +139 -0
  51. data/test/xmlss_writer/style_cache_test.rb +65 -0
  52. data/test/xmlss_writer/style_settings_test.rb +263 -0
  53. data/test/xmlss_writer/styles_test.rb +121 -153
  54. data/test/xmlss_writer_test.rb +91 -0
  55. metadata +75 -50
  56. data/lib/osheet/associations.rb +0 -58
  57. data/lib/osheet/instance.rb +0 -30
  58. data/lib/osheet/markup_element.rb +0 -22
  59. data/lib/osheet/partial_set.rb +0 -57
  60. data/lib/osheet/railtie.rb +0 -9
  61. data/lib/osheet/style_set.rb +0 -39
  62. data/lib/osheet/template_set.rb +0 -51
  63. data/lib/osheet/view_handler/rails.rb +0 -44
  64. data/lib/osheet/view_handler/tilt.rb +0 -42
  65. data/lib/osheet/view_handler.rb +0 -2
  66. data/lib/osheet/worksheet_element.rb +0 -17
  67. data/lib/osheet/xmlss_writer/base.rb +0 -49
  68. data/lib/osheet/xmlss_writer/elements.rb +0 -56
  69. data/lib/osheet/xmlss_writer/styles.rb +0 -216
  70. data/test/osheet_test.rb +0 -13
  71. data/test/partial_set_test.rb +0 -64
  72. data/test/style_set_test.rb +0 -47
  73. data/test/template_set_test.rb +0 -74
  74. data/test/xmlss_writer/base_test.rb +0 -103
  75. data/test/xmlss_writer/elements_test.rb +0 -172
@@ -0,0 +1,68 @@
1
+ class TestWriter
2
+
3
+ attr_accessor :styles, :worksheets, :columns, :rows, :cells
4
+
5
+ def initialize
6
+ @styles = []
7
+ @worksheets = []
8
+ @columns = []
9
+ @rows = []
10
+ @cells = []
11
+ end
12
+
13
+ def bind(workbook)
14
+ workbook
15
+ end
16
+
17
+ def style(obj, &block)
18
+ @styles << obj
19
+ block.call if !block.nil?
20
+ end
21
+
22
+ def worksheet(obj, &block)
23
+ @worksheets << obj
24
+ block.call if !block.nil?
25
+ end
26
+
27
+ def column(obj, &block)
28
+ @columns << obj
29
+ block.call if !block.nil?
30
+ end
31
+
32
+ def row(obj, &block)
33
+ @rows << obj
34
+ block.call if !block.nil?
35
+ end
36
+
37
+ def cell(obj, &block)
38
+ @cells << obj
39
+ block.call if !block.nil?
40
+ end
41
+
42
+ def style(*args)
43
+ return *args
44
+ end
45
+
46
+ [ :title, # workbook_element
47
+ :name, # worksheet
48
+ :meta, # worksheet, column, row, cell
49
+ :width, # column
50
+ :height, # row
51
+ :autofit, # column, row
52
+ :autofit?, # column, row
53
+ :hidden, # column, row
54
+ :hidden?, # column, row
55
+ :data, # cell
56
+ :href, # cell
57
+ :formula, # cell
58
+ :index, # cell
59
+ :rowspan, # cell
60
+ :colspan, # cell
61
+ ].each do |meth|
62
+ define_method(meth) do |*args|
63
+ # cool story bro (don't do anything, just allow)
64
+ return *args
65
+ end
66
+ end
67
+
68
+ end
data/test/format_test.rb CHANGED
@@ -3,8 +3,8 @@ require 'osheet/format'
3
3
 
4
4
  module Osheet
5
5
 
6
- class FormatTest < Assert::Context
7
- desc "Osheet::Format"
6
+ class FormatTests < Assert::Context
7
+ desc "a Format"
8
8
  before do
9
9
  @f = Format.new(:number, {
10
10
  :decimal_places => 4,
data/test/helper.rb CHANGED
@@ -3,104 +3,70 @@
3
3
  # add root dir to the load path
4
4
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
5
5
 
6
- require 'osheet'
7
-
8
6
  class Assert::Context
9
7
 
10
- def xstyle_markup(xworkbook)
11
- xworkbook.instance_variable_get("@__xmlss_undies_writer").flush.style_markup
8
+ def xmlss_style_markup(writer)
9
+ Xmlss::Workbook.writer(writer.xmlss_workbook).styles_markup.flush.to_s
12
10
  end
13
11
 
14
- def xelement_markup(xworkbook)
15
- xworkbook.instance_variable_get("@__xmlss_undies_writer").flush.element_markup
12
+ def xmlss_element_markup(writer)
13
+ Xmlss::Workbook.writer(writer.xmlss_workbook).worksheets_markup.flush.to_s
16
14
  end
17
15
 
18
- class << self
19
-
16
+ # Macros
20
17
 
21
- def should_be_a_workbook_element(klass)
22
- should have_instance_methods :workbook, :styles, :templates
18
+ def self.be_a_meta_element(*args)
19
+ called_from = caller.first
20
+ macro_name = "be a meta element"
23
21
 
24
- should "be able to read the workbook and it's styles/templates" do
25
- wkbk = Osheet::Workbook.new {
26
- template(:column, :thing) {}
27
- template(:row, :empty) {}
28
- style('.title') {
29
- font 14
30
- }
31
- style('.title', '.header') {
32
- font :bold
33
- }
34
- }
35
- klass = klass.new(wkbk)
22
+ Assert::Macro.new(macro_name) do
23
+ should have_instance_method :meta, [called_from]
36
24
 
37
- assert_equal wkbk, klass.workbook
38
- assert_equal wkbk.styles, klass.styles
39
- assert_equal wkbk.templates, klass.templates
25
+ should "default an empty meta value", called_from do
26
+ assert_equal nil, subject.class.new.meta
40
27
  end
41
- end
42
-
43
- def should_be_a_worksheet_element(klass)
44
- should have_instance_methods :worksheet, :columns
45
28
 
46
- should "be able to read the worksheet and it's columns" do
47
- wksht = Osheet::Worksheet.new {
48
- column {}
49
- column {}
50
- column {}
51
- }
52
- klass = klass.new(nil, wksht)
29
+ should "set meta info", called_from do
30
+ meta_elem = subject.class.new
53
31
 
54
- assert_equal wksht, klass.worksheet
55
- assert_equal wksht.columns, klass.columns
32
+ meta_elem.meta({:key => "value"})
33
+ assert_equal({:key => "value"}, meta_elem.meta)
56
34
  end
57
35
  end
36
+ end
37
+
38
+ def self.be_a_styled_element(*args)
39
+ called_from = caller.first
40
+ macro_name = "be a styled element"
58
41
 
59
- def should_be_a_styled_element(klass)
60
- should have_instance_methods :style_class
42
+ Assert::Macro.new(macro_name) do
43
+ should have_instance_method :style_class, [called_from]
61
44
 
62
- should "default an empty style class" do
63
- default = klass.new
64
- assert_equal nil, default.send(:get_ivar, "style_class")
45
+ should "default an empty style class", called_from do
46
+ assert_equal nil, subject.class.new.style_class
65
47
  end
66
48
 
67
- should "set a style class" do
68
- styled = klass.new{ style_class "awesome thing" }
69
- assert_equal "awesome thing", styled.send(:get_ivar, "style_class")
49
+ should "set a style class", called_from do
50
+ styled = subject.class.new
51
+ styled.style_class("awesome thing")
52
+ assert_equal "awesome thing", styled.style_class
70
53
  end
71
54
 
72
- should "verify the style class string" do
55
+ should "validate the style class string", called_from do
73
56
  ['.thing', 'thing.thing', 'thing .thing > thing', 'thin>g'].each do |s|
74
57
  assert_raises ArgumentError do
75
- klass.new { style_class s }
58
+ subject.class.new.style_class(s)
76
59
  end
77
60
  end
61
+
78
62
  ['thing', '#thing 123', 'thing-one thing_one'].each do |s|
79
63
  assert_nothing_raised do
80
- klass.new { style_class s }
64
+ subject.class.new.style_class(s)
81
65
  end
82
66
  end
83
67
  end
84
- end
85
-
86
- def should_hm(klass, collection, item_klass)
87
- should have_reader collection
88
- should have_instance_method collection.to_s.sub(/s$/, '')
89
-
90
- should "should initialize #{collection} and add them to it's collection" do
91
- singular = collection.to_s.sub(/s$/, '')
92
- thing = klass.new do
93
- self.send(singular) {}
94
- end
95
-
96
- items = thing.send(:get_ivar, collection)
97
- assert_equal items, thing.send(collection)
98
- assert !items.empty?
99
- assert_equal 1, items.size
100
- assert_kind_of item_klass, items.first
101
- end
102
68
 
103
69
  end
104
-
105
70
  end
71
+
106
72
  end
data/test/mixin_test.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  require "assert"
2
- require "test/mixins"
2
+ require "test/fixtures/mixins"
3
+ require 'osheet/workbook'
3
4
 
4
5
  module Osheet
5
6
 
6
- class MixinBaseTest < Assert::Context
7
- desc "Osheet::Mixin thing"
7
+ class MixinTests < Assert::Context
8
+ desc "a mixin"
8
9
  subject { DefaultMixin }
9
10
 
10
11
  should have_readers :styles, :templates, :partials
@@ -17,70 +18,63 @@ module Osheet
17
18
  end
18
19
  end
19
20
 
20
- class MixinStyleTest < Assert::Context
21
+ class MixinArgsTests < MixinTests
22
+ desc "args class"
23
+ before do
24
+ @build_block = Proc.new {}
25
+ @ma = Mixin::Args.new('some', 'args', 'here', &@build_block)
26
+ end
27
+ subject { @ma }
28
+
29
+ should have_readers :args, :build
30
+
31
+ should "collect arguments" do
32
+ assert_equal ['some', 'args', 'here'], subject.args
33
+ end
34
+
35
+ should "store a build block" do
36
+ assert_same @build_block, subject.build
37
+ end
38
+
39
+ should "default with empty args and an empty Proc build" do
40
+ default = Mixin::Args.new
41
+
42
+ assert_empty default.args
43
+ assert_kind_of Proc, default.build
44
+ end
45
+
46
+ end
47
+
48
+ class MixinStyleTests < Assert::Context
21
49
  desc "that defines styles"
22
50
  subject { StyledMixin }
23
51
 
24
52
  should "have it's styles defined" do
25
53
  assert_equal 2, subject.styles.size
26
- assert_equal 1, subject.styles.first.selectors.size
27
- assert_equal '.test', subject.styles.first.selectors.first
28
- assert_equal 1, subject.styles.last.selectors.size
29
- assert_equal '.test.awesome', subject.styles.last.selectors.first
54
+ assert_kind_of Mixin::Args, subject.styles.first
30
55
  end
31
56
  end
32
57
 
33
- class MixinTemplateTest < Assert::Context
58
+ class MixinTemplateTests < Assert::Context
34
59
  desc "that defines templates"
35
60
  subject { TemplatedMixin }
36
61
 
37
62
  should "have it's templates defined" do
38
63
  assert subject.templates
39
64
  assert_equal 3, subject.templates.size
40
- assert_kind_of Template, subject.templates.first
65
+ assert_kind_of Mixin::Args, subject.templates.first
41
66
  end
42
67
  end
43
68
 
44
- class MixinPartialTest < Assert::Context
69
+ class MixinPartialTests < Assert::Context
45
70
  desc "that defines partials"
46
71
  subject { PartialedMixin }
47
72
 
48
73
  should "have it's partials defined" do
49
74
  assert subject.partials
50
75
  assert_equal 2, subject.partials.size
51
- assert_kind_of Partial, subject.partials.first
52
- end
53
- end
54
-
55
- class MixinUseTest < Assert::Context
56
- desc "A workbook that uses mixins"
57
- setup do
58
- @workbook = Osheet::Workbook.new do
59
- use PartialedMixin
60
- use TemplatedMixin
61
- use StyledMixin
62
- end
63
- end
64
- subject { @workbook }
65
-
66
- should "have mixin partials" do
67
- workbook_partials = @workbook.partials.values
68
- PartialedMixin.partials.each do |partial|
69
- assert workbook_partials.include?(partial)
70
- end
76
+ assert_kind_of Mixin::Args, subject.partials.first
71
77
  end
72
-
73
- should "have mixin templates" do
74
- workbook_templates = @workbook.templates.values.collect{ |t| t.values.first }
75
- TemplatedMixin.templates.each do |template|
76
- assert workbook_templates.include?(template)
77
- end
78
- end
79
-
80
- should "have mixin styles" do
81
- assert_equal StyledMixin.styles, @workbook.styles
82
- end
83
-
84
78
  end
85
79
 
86
80
  end
data/test/partial_test.rb CHANGED
@@ -1,20 +1,19 @@
1
1
  require "assert"
2
+
2
3
  require "osheet/partial"
3
4
 
4
5
  module Osheet
5
6
  class PartialTest < Assert::Context
6
- desc "Osheet::Partial"
7
+ desc "a Partial"
7
8
  before { @p = Partial.new(:thing) {} }
8
9
  subject { @p }
9
10
 
10
- should have_accessor :name
11
-
12
11
  should "be a Proc" do
13
12
  assert_kind_of ::Proc, subject
14
13
  end
15
14
 
16
15
  should "convert the name arg to a string and store off" do
17
- assert_equal 'thing', subject.name
16
+ assert_equal 'thing', subject.instance_variable_get("@name")
18
17
  end
19
18
 
20
19
  end
@@ -39,26 +38,4 @@ module Osheet
39
38
 
40
39
  end
41
40
 
42
- class PartialBindingTest < Assert::Context
43
- desc "a partial defined w/ a block"
44
-
45
- should "access instance vars from that block's binding" do
46
- @test = 'test thing'
47
- @workbook = Workbook.new {
48
- partial(:stuff) {
49
- worksheet(:thing) { name @test }
50
- }
51
-
52
- add(:stuff)
53
- }
54
-
55
- assert !@workbook.worksheets.first.send(:instance_variable_get, "@test").nil?
56
- assert_equal @test, @workbook.worksheets.first.send(:instance_variable_get, "@test")
57
- assert_equal @test.object_id, @workbook.worksheets.first.send(:instance_variable_get, "@test").object_id
58
- assert_equal @test, @workbook.worksheets.first.attributes[:name]
59
- assert_equal @test.object_id, @workbook.worksheets.first.attributes[:name].object_id
60
- end
61
-
62
- end
63
-
64
41
  end
data/test/row_test.rb CHANGED
@@ -1,124 +1,71 @@
1
1
  require "assert"
2
+
3
+ require 'osheet/cell'
2
4
  require 'osheet/row'
3
5
 
4
6
  module Osheet
5
7
 
6
- class RowTest < Assert::Context
7
- desc "Osheet::Row"
8
+ class RowTests < Assert::Context
9
+ desc "a Row"
8
10
  before { @rw = Row.new }
9
11
  subject { @rw }
10
12
 
11
- should_be_a_styled_element(Row)
12
- should_be_a_worksheet_element(Row)
13
- should_be_a_workbook_element(Row)
13
+ should be_a_styled_element
14
+ should be_a_meta_element
14
15
 
15
- should have_instance_method :height
16
+ should have_reader :format
17
+ should have_instance_methods :height
16
18
  should have_instance_methods :autofit, :autofit?
17
19
  should have_instance_methods :hidden, :hidden?
18
- should have_instance_method :meta
19
-
20
- should_hm(Row, :cells, Cell)
20
+ should have_instance_methods :cells, :cell
21
21
 
22
22
  should "set it's defaults" do
23
- assert_equal nil, subject.send(:get_ivar, "height")
24
- assert_equal false, subject.send(:get_ivar, "autofit")
23
+ assert_equal nil, subject.height
24
+ assert_equal false, subject.autofit
25
25
  assert !subject.autofit?
26
- assert_equal false, subject.send(:get_ivar, "hidden")
26
+ assert_equal false, subject.hidden
27
27
  assert !subject.hidden?
28
-
29
- assert_equal [], subject.cells
30
- assert_equal nil, subject.meta
28
+ assert_kind_of Format::General, subject.format
31
29
  end
32
30
 
33
- should "set it's height" do
31
+ should "set it's width" do
34
32
  subject.height(false)
35
33
  assert_equal false, subject.height
34
+
36
35
  subject.height(180)
37
36
  assert_equal 180, subject.height
37
+
38
38
  subject.height(nil)
39
39
  assert_equal 180, subject.height
40
- end
41
-
42
- should "cast autofit and hidden to bool" do
43
- rw = Row.new { autofit :true; hidden 'false'}
44
- assert_kind_of ::TrueClass, rw.send(:get_ivar, "autofit")
45
- assert_kind_of ::TrueClass, rw.send(:get_ivar, "hidden")
46
- end
47
40
 
48
- end
49
-
50
- class RowAttributeTest < RowTest
51
- desc "a row that has attributes"
52
- before do
53
- @rw = Row.new do
54
- style_class "poo"
55
- height 100
56
- autofit true
57
- hidden true
58
- meta(
59
- {}
60
- )
61
- end
41
+ assert_equal 200, Row.new(200).height
62
42
  end
63
43
 
64
- should "should set them correctly" do
65
- assert_equal 100, subject.send(:get_ivar, "height")
66
- assert_equal true, subject.send(:get_ivar, "autofit")
67
- assert subject.autofit?
68
- assert_equal true, subject.send(:get_ivar, "hidden")
69
- assert subject.hidden?
70
- assert_equal({}, subject.meta)
71
- end
44
+ should "cast autofit and hidden to bool" do
45
+ row = Row.new
46
+ row.autofit :true
47
+ row.hidden 'false'
72
48
 
73
- should "know it's attribute(s)" do
74
- [:style_class, :height, :autofit, :hidden].each do |a|
75
- assert subject.attributes.has_key?(a)
76
- end
77
- assert_equal 'poo', subject.attributes[:style_class]
78
- assert_equal 100, subject.attributes[:height]
79
- assert_equal true, subject.attributes[:autofit]
80
- assert_equal true, subject.attributes[:hidden]
49
+ assert_equal true, row.autofit
50
+ assert_equal true, row.hidden
81
51
  end
82
52
 
83
53
  end
84
54
 
85
- class RowPartialTest < Assert::Context
86
- desc "A workbook that defines column partials"
87
- before do
88
- @wkbk = Workbook.new {
89
- partial(:row_stuff) {
90
- height 200
91
- meta 'awesome'
92
- }
93
-
94
- worksheet { row {
95
- add :row_stuff
96
- } }
97
- }
98
- end
99
- subject { @wkbk }
55
+ class RowCellTests < RowTests
56
+ desc "with cells"
57
+ before {
58
+ @cell = Cell.new
59
+ @rw.cell(@cell)
60
+ }
100
61
 
101
- should "add it's partials to it's markup" do
102
- assert_equal 200, subject.worksheets.first.rows.first.height
103
- assert_equal 'awesome', subject.worksheets.first.rows.first.meta
62
+ should "know its cells" do
63
+ assert_equal 1, subject.cells.size
64
+ assert_same @cell, subject.cells.first
104
65
  end
105
66
 
106
67
  end
107
68
 
108
- class RowBindingTest < Assert::Context
109
- desc "a row defined w/ a block"
110
69
 
111
- should "access instance vars from that block's binding" do
112
- @test = 50
113
- @row = Row.new { height @test }
114
-
115
- assert !@row.send(:instance_variable_get, "@test").nil?
116
- assert_equal @test, @row.send(:instance_variable_get, "@test")
117
- assert_equal @test.object_id, @row.send(:instance_variable_get, "@test").object_id
118
- assert_equal @test, @row.attributes[:height]
119
- assert_equal @test.object_id, @row.attributes[:height].object_id
120
- end
121
-
122
- end
123
70
 
124
71
  end
data/test/style_test.rb CHANGED
@@ -1,16 +1,18 @@
1
1
  require "assert"
2
+
2
3
  require "osheet/style"
3
4
 
4
5
  module Osheet
5
6
 
6
7
  class StyleTest < Assert::Context
7
- desc "Osheet::Style"
8
+ desc "a Style"
8
9
  before { @st = Style.new('.test') }
9
10
  subject { @st }
10
11
 
11
- should have_reader :selectors
12
- should have_instance_methods :align, :font, :bg
13
- should have_instance_methods :border, :border_left, :border_top, :border_right, :border_bottom
12
+ should have_reader :selectors, :build
13
+ should have_instance_methods :align, :font, :bg, :border
14
+ should have_instance_methods :border_left, :border_top
15
+ should have_instance_methods :border_right, :border_bottom
14
16
  should have_instance_method :match?
15
17
 
16
18
  should "set it's defaults" do
@@ -19,15 +21,7 @@ module Osheet
19
21
  [ :align, :font, :bg,
20
22
  :border_left, :border_top, :border_right, :border_bottom
21
23
  ].each do |a|
22
- assert_equal [], subject.send(:get_ivar, a)
23
- end
24
- end
25
-
26
- should "know it's attribute(s)" do
27
- [ :align, :font, :bg,
28
- :border_left, :border_top, :border_right, :border_bottom
29
- ].each do |a|
30
- assert subject.attributes.has_key?(a)
24
+ assert_equal [], subject.send(a)
31
25
  end
32
26
  end
33
27
 
@@ -53,7 +47,7 @@ module Osheet
53
47
  should "collect styles for #{a}" do
54
48
  args = [1, "#FF0000", "Verdana", :love, 1.2]
55
49
  subject.send(a, *args)
56
- assert_equal args, subject.send(:get_ivar, a)
50
+ assert_equal args, subject.send(a)
57
51
  end
58
52
  end
59
53
 
@@ -61,7 +55,7 @@ module Osheet
61
55
  args = [:thick, '#FF00FF', :dot]
62
56
  subject.border *args
63
57
  [ :border_left, :border_top, :border_right, :border_bottom].each do |a|
64
- assert_equal args, subject.send(:get_ivar, a)
58
+ assert_equal args, subject.send(a)
65
59
  end
66
60
  end
67
61
 
@@ -88,17 +82,6 @@ module Osheet
88
82
  assert_equal false, a.match?('stupid')
89
83
  end
90
84
 
91
- should "access instance vars from that block's binding" do
92
- @test = 20
93
- @style = Style.new('.test') { font @test }
94
-
95
- assert !@style.send(:instance_variable_get, "@test").nil?
96
- assert_equal @test, @style.send(:instance_variable_get, "@test")
97
- assert_equal @test.object_id, @style.send(:instance_variable_get, "@test").object_id
98
- assert_equal @test, @style.attributes[:font].first
99
- assert_equal @test.object_id, @style.attributes[:font].first.object_id
100
- end
101
-
102
85
  end
103
86
 
104
87
  end
@@ -1,10 +1,11 @@
1
1
  require "assert"
2
+
2
3
  require "osheet/template"
3
4
 
4
5
  module Osheet
5
6
 
6
- class TemplateTest < Assert::Context
7
- desc "Osheet::Template"
7
+ class TemplateTests < Assert::Context
8
+ desc "a Template"
8
9
  before do
9
10
  @tmpl = Template.new('column', :thing) {}
10
11
  end
@@ -14,19 +15,17 @@ module Osheet
14
15
  assert_equal ['worksheet', 'column', 'row', 'cell'], Template::ELEMENTS
15
16
  end
16
17
 
17
- should have_accessor :element
18
-
19
18
  should "be a Partial" do
20
19
  assert_kind_of Partial, subject
21
20
  end
22
21
 
23
22
  should "convert the element ars to string and store off" do
24
- assert_equal 'column', subject.element
23
+ assert_equal 'column', subject.instance_variable_get("@element")
25
24
  end
26
25
 
27
26
  end
28
27
 
29
- class TemplateElementTest < TemplateTest
28
+ class TemplateElementTest < TemplateTests
30
29
  desc "a template"
31
30
 
32
31
  should "verify the element argument" do