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
@@ -1,116 +1,114 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/scientific'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class ScientificTest < Test::Unit::TestCase
7
- context "Scientific format" do
8
- subject { Scientific.new }
6
+ class ScientificTest < Assert::Context
7
+ desc "Scientific format"
8
+ before { @sc = Scientific.new }
9
+ subject { @sc }
9
10
 
10
- should_have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
11
+ should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
11
12
 
12
- should "provide negative numbers options" do
13
- assert_equal 4, Scientific.negative_numbers_set.size
14
- [:black, :black_parenth, :red, :red_parenth].each do |a|
15
- assert Scientific.negative_numbers_set.include?(a)
16
- end
13
+ should "provide negative numbers options" do
14
+ assert_equal 4, Scientific.negative_numbers_set.size
15
+ [:black, :black_parenth, :red, :red_parenth].each do |a|
16
+ assert Scientific.negative_numbers_set.include?(a)
17
17
  end
18
+ end
18
19
 
19
- should "set default values" do
20
- assert_equal 2, subject.decimal_places
21
- assert_equal false, subject.comma_separator
22
- assert_equal :black, subject.negative_numbers
23
- end
20
+ should "set default values" do
21
+ assert_equal 2, subject.decimal_places
22
+ assert_equal false, subject.comma_separator
23
+ assert_equal :black, subject.negative_numbers
24
+ end
24
25
 
25
- should "only allow Fixnum decimal places between 0 and 30" do
26
- assert_raises ArgumentError do
27
- Scientific.new({:decimal_places => -1})
28
- end
29
- assert_raises ArgumentError do
30
- Scientific.new({:decimal_places => 31})
31
- end
32
- assert_raises ArgumentError do
33
- Scientific.new({:decimal_places => 'poo'})
34
- end
35
- assert_nothing_raised do
36
- Scientific.new({:decimal_places => 1})
37
- end
26
+ should "only allow Fixnum decimal places between 0 and 30" do
27
+ assert_raises ArgumentError do
28
+ Scientific.new({:decimal_places => -1})
38
29
  end
39
-
40
- should "generate decimal place style strings" do
41
- assert_equal "0E+00", Scientific.new({
42
- :decimal_places => 0
43
- }).style
44
- (1..5).each do |n|
45
- assert_equal "0.#{'0'*n}E+00", Scientific.new({
46
- :decimal_places => n
47
- }).style
48
- end
30
+ assert_raises ArgumentError do
31
+ Scientific.new({:decimal_places => 31})
49
32
  end
50
-
51
- should "generate comma separator style strings" do
52
- assert_equal "0E+00", Scientific.new({
53
- :comma_separator => false,
54
- :decimal_places => 0
55
- }).style
56
- assert_equal "#,##0E+00", Scientific.new({
57
- :comma_separator => true,
58
- :decimal_places => 0
59
- }).style
33
+ assert_raises ArgumentError do
34
+ Scientific.new({:decimal_places => 'poo'})
60
35
  end
61
-
62
- should "generate parenth negative numbers style strings" do
63
- assert_equal "0E+00", Scientific.new({
64
- :negative_numbers => :black,
65
- :decimal_places => 0
66
- }).style
67
- assert_equal "0E+00_);\(0E+00\)", Scientific.new({
68
- :negative_numbers => :black_parenth,
69
- :decimal_places => 0
70
- }).style
36
+ assert_nothing_raised do
37
+ Scientific.new({:decimal_places => 1})
71
38
  end
39
+ end
72
40
 
73
- should "generate red negative numbers style strings" do
74
- assert_equal "0E+00;[Red]0E+00", Scientific.new({
75
- :negative_numbers => :red,
76
- :decimal_places => 0
77
- }).style
78
- assert_equal "0E+00_);[Red]\(0E+00\)", Scientific.new({
79
- :negative_numbers => :red_parenth,
80
- :decimal_places => 0
41
+ should "generate decimal place style strings" do
42
+ assert_equal "0E+00", Scientific.new({
43
+ :decimal_places => 0
44
+ }).style
45
+ (1..5).each do |n|
46
+ assert_equal "0.#{'0'*n}E+00", Scientific.new({
47
+ :decimal_places => n
81
48
  }).style
82
49
  end
50
+ end
83
51
 
84
- should "generate complex style string" do
85
- assert_equal("0.00E+00_);\(0.00E+00\)", Scientific.new({
86
- :decimal_places => 2,
87
- :negative_numbers => :black_parenth,
88
- :comma_separator => false
89
- }).style)
90
- assert_equal("#,##0.0000E+00_);[Red]\(#,##0.0000E+00\)", Scientific.new({
91
- :decimal_places => 4,
92
- :negative_numbers => :red_parenth,
93
- :comma_separator => true
94
- }).style)
95
- end
52
+ should "generate comma separator style strings" do
53
+ assert_equal "0E+00", Scientific.new({
54
+ :comma_separator => false,
55
+ :decimal_places => 0
56
+ }).style
57
+ assert_equal "#,##0E+00", Scientific.new({
58
+ :comma_separator => true,
59
+ :decimal_places => 0
60
+ }).style
61
+ end
96
62
 
97
- should "provide unique format keys" do
98
- assert_equal("scientific_none_2_nocomma_blackparenth", Scientific.new({
99
- :decimal_places => 2,
100
- :negative_numbers => :black_parenth,
101
- :comma_separator => false
102
- }).key)
103
- assert_equal("scientific_none_4_comma_redparenth", Scientific.new({
104
- :symbol => :none,
105
- :decimal_places => 4,
106
- :negative_numbers => :red_parenth,
107
- :comma_separator => true
108
- }).key)
109
- end
63
+ should "generate parenth negative numbers style strings" do
64
+ assert_equal "0E+00", Scientific.new({
65
+ :negative_numbers => :black,
66
+ :decimal_places => 0
67
+ }).style
68
+ assert_equal "0E+00_);\(0E+00\)", Scientific.new({
69
+ :negative_numbers => :black_parenth,
70
+ :decimal_places => 0
71
+ }).style
72
+ end
110
73
 
74
+ should "generate red negative numbers style strings" do
75
+ assert_equal "0E+00;[Red]0E+00", Scientific.new({
76
+ :negative_numbers => :red,
77
+ :decimal_places => 0
78
+ }).style
79
+ assert_equal "0E+00_);[Red]\(0E+00\)", Scientific.new({
80
+ :negative_numbers => :red_parenth,
81
+ :decimal_places => 0
82
+ }).style
83
+ end
111
84
 
85
+ should "generate complex style string" do
86
+ assert_equal("0.00E+00_);\(0.00E+00\)", Scientific.new({
87
+ :decimal_places => 2,
88
+ :negative_numbers => :black_parenth,
89
+ :comma_separator => false
90
+ }).style)
91
+ assert_equal("#,##0.0000E+00_);[Red]\(#,##0.0000E+00\)", Scientific.new({
92
+ :decimal_places => 4,
93
+ :negative_numbers => :red_parenth,
94
+ :comma_separator => true
95
+ }).style)
96
+ end
112
97
 
98
+ should "provide unique format keys" do
99
+ assert_equal("scientific_none_2_nocomma_blackparenth", Scientific.new({
100
+ :decimal_places => 2,
101
+ :negative_numbers => :black_parenth,
102
+ :comma_separator => false
103
+ }).key)
104
+ assert_equal("scientific_none_4_comma_redparenth", Scientific.new({
105
+ :symbol => :none,
106
+ :decimal_places => 4,
107
+ :negative_numbers => :red_parenth,
108
+ :comma_separator => true
109
+ }).key)
113
110
  end
111
+
114
112
  end
115
113
 
116
114
  end
@@ -1,51 +1,51 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/special'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class SpecialTest < Test::Unit::TestCase
7
- context "Special format" do
8
- subject { Special.new }
6
+ class SpecialTest < Assert::Context
7
+ desc "Special format"
8
+ before { @sp = Special.new }
9
+ subject { @sp }
9
10
 
10
- should_have_accessors :type
11
+ should have_accessors :type
11
12
 
12
- should "provide options for type" do
13
- assert_equal 4, Special.type_set.size
14
- [ :zip_code, :zip_code_plus_4, :phone_number, :social_security_number].each do |a|
15
- assert Special.type_set.include?(a)
16
- end
17
- end
18
-
19
- should "set default values" do
20
- assert_equal nil, subject.type
21
- assert_equal nil, subject.type_key
13
+ should "provide options for type" do
14
+ assert_equal 4, Special.type_set.size
15
+ [ :zip_code, :zip_code_plus_4, :phone_number, :social_security_number].each do |a|
16
+ assert Special.type_set.include?(a)
22
17
  end
18
+ end
23
19
 
24
- should "generate a zip_code type style strings and key" do
25
- f = Special.new(:type => :zip_code)
26
- assert_equal "00000", f.style
27
- assert_equal "special_zipcode", f.key
28
- end
20
+ should "set default values" do
21
+ assert_equal nil, subject.type
22
+ assert_equal nil, subject.type_key
23
+ end
29
24
 
30
- should "generate a zip_code_plus_4 type style strings and key" do
31
- f = Special.new(:type => :zip_code_plus_4)
32
- assert_equal "00000-0000", f.style
33
- assert_equal "special_zipcodeplus4", f.key
34
- end
25
+ should "generate a zip_code type style strings and key" do
26
+ f = Special.new(:type => :zip_code)
27
+ assert_equal "00000", f.style
28
+ assert_equal "special_zipcode", f.key
29
+ end
35
30
 
36
- should "generate a phone_number type style strings and key" do
37
- f = Special.new(:type => :phone_number)
38
- assert_equal "[<=9999999]###-####;(###) ###-####", f.style
39
- assert_equal "special_phonenumber", f.key
40
- end
31
+ should "generate a zip_code_plus_4 type style strings and key" do
32
+ f = Special.new(:type => :zip_code_plus_4)
33
+ assert_equal "00000-0000", f.style
34
+ assert_equal "special_zipcodeplus4", f.key
35
+ end
41
36
 
42
- should "generate a social_security_number type style strings and key" do
43
- f = Special.new(:type => :social_security_number)
44
- assert_equal "000-00-0000", f.style
45
- assert_equal "special_socialsecuritynumber", f.key
46
- end
37
+ should "generate a phone_number type style strings and key" do
38
+ f = Special.new(:type => :phone_number)
39
+ assert_equal "[<=9999999]###-####;(###) ###-####", f.style
40
+ assert_equal "special_phonenumber", f.key
41
+ end
47
42
 
43
+ should "generate a social_security_number type style strings and key" do
44
+ f = Special.new(:type => :social_security_number)
45
+ assert_equal "000-00-0000", f.style
46
+ assert_equal "special_socialsecuritynumber", f.key
48
47
  end
48
+
49
49
  end
50
50
 
51
51
  end
@@ -1,18 +1,18 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/text'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class TextTest < Test::Unit::TestCase
7
- context "Text format" do
8
- subject { Text.new }
9
-
10
- should "generate a style strings and key" do
11
- assert_equal "@", subject.style
12
- assert_equal "text", subject.key
13
- end
6
+ class TextTest < Assert::Context
7
+ desc "Text format"
8
+ before { @txt = Text.new }
9
+ subject { @txt }
14
10
 
11
+ should "generate a style strings and key" do
12
+ assert_equal "@", subject.style
13
+ assert_equal "text", subject.key
15
14
  end
15
+
16
16
  end
17
17
 
18
18
  end
data/test/format_test.rb CHANGED
@@ -1,35 +1,35 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format'
3
3
 
4
4
  module Osheet
5
5
 
6
- class FormatTest < Test::Unit::TestCase
7
- context "Osheet::Format" do
8
- subject do
9
- Format.new(:number, {
10
- :decimal_places => 4,
11
- :comma_separator => true,
12
- :negative_numbers => :black_parenth
13
- })
14
- end
6
+ class FormatTest < Assert::Context
7
+ desc "Osheet::Format"
8
+ before do
9
+ @f = Format.new(:number, {
10
+ :decimal_places => 4,
11
+ :comma_separator => true,
12
+ :negative_numbers => :black_parenth
13
+ })
14
+ end
15
+ subject { @f }
15
16
 
16
- should "build format class instances" do
17
- assert_kind_of Format::Number, subject
18
- assert_equal 4, subject.decimal_places
19
- assert_equal true, subject.comma_separator
20
- assert_equal :black_parenth, subject.negative_numbers
21
- end
17
+ should "build format class instances" do
18
+ assert_kind_of Format::Number, subject
19
+ assert_equal 4, subject.decimal_places
20
+ assert_equal true, subject.comma_separator
21
+ assert_equal :black_parenth, subject.negative_numbers
22
+ end
22
23
 
23
- should "error for invalid format types" do
24
- assert_raises ArgumentError do
25
- Format.new(:awesome, {})
26
- end
27
- assert_nothing_raised do
28
- Format.new(:general)
29
- end
24
+ should "error for invalid format types" do
25
+ assert_raises ArgumentError do
26
+ Format.new(:awesome, {})
27
+ end
28
+ assert_nothing_raised do
29
+ Format.new(:general)
30
30
  end
31
-
32
31
  end
32
+
33
33
  end
34
34
 
35
35
  end
data/test/helper.rb CHANGED
@@ -1,66 +1,61 @@
1
- require 'rubygems'
2
- require 'test_belt'
3
- require 'test/env'
1
+ # this file is automatically required in when you require 'assert' in your tests
4
2
 
5
- class Test::Unit::TestCase
3
+ # add root dir to the load path
4
+ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
5
+
6
+ require 'osheet'
7
+
8
+ class Assert::Context
6
9
  class << self
7
10
 
8
11
 
9
12
  def should_be_a_workbook_element(klass)
10
- should_have_instance_methods :workbook, :styles, :templates
11
- context "given a workbook with templates and styles" do
12
- before do
13
- @wkbk = Osheet::Workbook.new {
14
- template(:column, :thing) {}
15
- template(:row, :empty) {}
16
- style('.title') {
17
- font 14
18
- }
19
- style('.title', '.header') {
20
- font :bold
21
- }
13
+ should have_instance_methods :workbook, :styles, :templates
14
+
15
+ should "be able to read the workbook and it's styles/templates" do
16
+ wkbk = Osheet::Workbook.new {
17
+ template(:column, :thing) {}
18
+ template(:row, :empty) {}
19
+ style('.title') {
20
+ font 14
22
21
  }
23
- @klass = klass.new(@wkbk)
24
- end
22
+ style('.title', '.header') {
23
+ font :bold
24
+ }
25
+ }
26
+ klass = klass.new(wkbk)
25
27
 
26
- should "be able to read the workbook and it's styles/templates" do
27
- assert_equal @wkbk, @klass.workbook
28
- assert_equal @wkbk.styles, @klass.styles
29
- assert_equal @wkbk.templates, @klass.templates
30
- end
28
+ assert_equal wkbk, klass.workbook
29
+ assert_equal wkbk.styles, klass.styles
30
+ assert_equal wkbk.templates, klass.templates
31
31
  end
32
32
  end
33
33
 
34
34
  def should_be_a_worksheet_element(klass)
35
- should_have_instance_methods :worksheet, :columns
36
- context "given a worksheet with columns" do
37
- before do
38
- @wksht = Osheet::Worksheet.new {
39
- column {}
40
- column {}
41
- column {}
42
- }
43
- @klass = klass.new(nil, @wksht)
44
- end
35
+ should have_instance_methods :worksheet, :columns
45
36
 
46
- should "be able to read the worksheet and it's columns" do
47
- assert_equal @wksht, @klass.worksheet
48
- assert_equal @wksht.columns, @klass.columns
49
- end
37
+ should "be able to read the worksheet and it's columns" do
38
+ wksht = Osheet::Worksheet.new {
39
+ column {}
40
+ column {}
41
+ column {}
42
+ }
43
+ klass = klass.new(nil, wksht)
44
+
45
+ assert_equal wksht, klass.worksheet
46
+ assert_equal wksht.columns, klass.columns
50
47
  end
51
48
  end
52
49
 
53
50
  def should_be_a_styled_element(klass)
54
- should_have_instance_methods :style_class
51
+ should have_instance_methods :style_class
55
52
 
56
- context "by default" do
57
- before { @default = klass.new }
58
- should "default an empty style class" do
59
- assert_equal nil, @default.send(:get_ivar, "style_class")
60
- end
53
+ should "default an empty style class" do
54
+ default = klass.new
55
+ assert_equal nil, default.send(:get_ivar, "style_class")
61
56
  end
62
57
 
63
- should "default an empty style class" do
58
+ should "set a style class" do
64
59
  styled = klass.new{ style_class "awesome thing" }
65
60
  assert_equal "awesome thing", styled.send(:get_ivar, "style_class")
66
61
  end
@@ -80,8 +75,8 @@ class Test::Unit::TestCase
80
75
  end
81
76
 
82
77
  def should_hm(klass, collection, item_klass)
83
- should_have_reader collection
84
- should_have_instance_method collection.to_s.sub(/s$/, '')
78
+ should have_reader collection
79
+ should have_instance_method collection.to_s.sub(/s$/, '')
85
80
 
86
81
  should "should initialize #{collection} and add them to it's collection" do
87
82
  singular = collection.to_s.sub(/s$/, '')
@@ -99,4 +94,4 @@ class Test::Unit::TestCase
99
94
  end
100
95
 
101
96
  end
102
- end
97
+ end
data/test/irb.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'assert/setup'
2
+
3
+ # this file is required in when the 'irb' rake test is run.
4
+ # b/c 'assert' is required above, the test helper will be
5
+ # required in.
6
+
7
+ # put any IRB setup code here
8
+
9
+ require 'osheet'
data/test/mixin_test.rb CHANGED
@@ -1,90 +1,86 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require "test/mixins"
3
3
 
4
4
  module Osheet
5
5
 
6
- class MixinBaseTest < Test::Unit::TestCase
7
- context "Osheet::Mixin thing" do
8
- subject { DefaultMixin }
6
+ class MixinBaseTest < Assert::Context
7
+ desc "Osheet::Mixin thing"
8
+ subject { DefaultMixin }
9
9
 
10
- should_have_readers :styles, :templates, :partials
11
- should_have_instance_methods :style, :template, :partial
10
+ should have_readers :styles, :templates, :partials
11
+ should have_instance_methods :style, :template, :partial
12
12
 
13
- should "set it's defaults" do
14
- assert_equal [], subject.styles
15
- assert_equal [], subject.templates
16
- assert_equal [], subject.partials
17
- end
13
+ should "set it's defaults" do
14
+ assert_equal [], subject.styles
15
+ assert_equal [], subject.templates
16
+ assert_equal [], subject.partials
18
17
  end
19
18
  end
20
19
 
21
- class MixinStyleTest < Test::Unit::TestCase
22
- context "that defines styles" do
23
- subject { StyledMixin }
20
+ class MixinStyleTest < Assert::Context
21
+ desc "that defines styles"
22
+ subject { StyledMixin }
24
23
 
25
- should "have it's styles defined" do
26
- assert_equal 2, subject.styles.size
27
- assert_equal 1, subject.styles.first.selectors.size
28
- assert_equal '.test', subject.styles.first.selectors.first
29
- assert_equal 1, subject.styles.last.selectors.size
30
- assert_equal '.test.awesome', subject.styles.last.selectors.first
31
- end
24
+ should "have it's styles defined" do
25
+ 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
32
30
  end
33
31
  end
34
32
 
35
- class MixinTemplateTest < Test::Unit::TestCase
36
- context "that defines templates" do
37
- subject { TemplatedMixin }
33
+ class MixinTemplateTest < Assert::Context
34
+ desc "that defines templates"
35
+ subject { TemplatedMixin }
38
36
 
39
- should "have it's templates defined" do
40
- assert subject.templates
41
- assert_equal 3, subject.templates.size
42
- assert_kind_of Template, subject.templates.first
43
- end
37
+ should "have it's templates defined" do
38
+ assert subject.templates
39
+ assert_equal 3, subject.templates.size
40
+ assert_kind_of Template, subject.templates.first
44
41
  end
45
42
  end
46
43
 
47
- class MixinPartialTest < Test::Unit::TestCase
48
- context "that defines partials" do
49
- subject { PartialedMixin }
44
+ class MixinPartialTest < Assert::Context
45
+ desc "that defines partials"
46
+ subject { PartialedMixin }
50
47
 
51
- should "have it's partials defined" do
52
- assert subject.partials
53
- assert_equal 2, subject.partials.size
54
- assert_kind_of Partial, subject.partials.first
55
- end
48
+ should "have it's partials defined" do
49
+ assert subject.partials
50
+ assert_equal 2, subject.partials.size
51
+ assert_kind_of Partial, subject.partials.first
56
52
  end
57
53
  end
58
54
 
59
- class MixinUseTest < Test::Unit::TestCase
60
- context "A workbook that uses mixins" do
61
- setup do
62
- @workbook = Osheet::Workbook.new do
63
- use PartialedMixin
64
- use TemplatedMixin
65
- use StyledMixin
66
- end
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
67
62
  end
68
- subject { @workbook }
63
+ end
64
+ subject { @workbook }
69
65
 
70
- should "have mixin partials" do
71
- workbook_partials = @workbook.partials.values
72
- PartialedMixin.partials.each do |partial|
73
- assert workbook_partials.include?(partial)
74
- end
66
+ should "have mixin partials" do
67
+ workbook_partials = @workbook.partials.values
68
+ PartialedMixin.partials.each do |partial|
69
+ assert workbook_partials.include?(partial)
75
70
  end
71
+ end
76
72
 
77
- should "have mixin templates" do
78
- workbook_templates = @workbook.templates.values.collect{ |t| t.values.first }
79
- TemplatedMixin.templates.each do |template|
80
- assert workbook_templates.include?(template)
81
- end
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)
82
77
  end
78
+ end
83
79
 
84
- should "have mixin styles" do
85
- assert_equal StyledMixin.styles, @workbook.styles
86
- end
80
+ should "have mixin styles" do
81
+ assert_equal StyledMixin.styles, @workbook.styles
87
82
  end
83
+
88
84
  end
89
85
 
90
86
  end