osheet 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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,158 +1,145 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/accounting'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class AccountingTest < Test::Unit::TestCase
7
- context "Accounting format" do
8
- subject { Accounting.new }
6
+ class AccountingTest < Assert::Context
7
+ desc "Accounting format"
8
+ before { @f = Accounting.new }
9
+ subject { @f }
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 symbol options" do
13
- assert_equal 3, Accounting.symbol_set.size
14
- [:none, :dollar, :euro].each do |a|
15
- assert Accounting.symbol_set.include?(a)
16
- end
13
+ should "provide symbol options" do
14
+ assert_equal 3, Accounting.symbol_set.size
15
+ [:none, :dollar, :euro].each do |a|
16
+ assert Accounting.symbol_set.include?(a)
17
17
  end
18
+ end
18
19
 
19
- should "provide negative numbers options" do
20
- assert_equal 4, Accounting.negative_numbers_set.size
21
- [:black, :black_parenth, :red, :red_parenth].each do |a|
22
- assert Accounting.negative_numbers_set.include?(a)
23
- end
20
+ should "provide negative numbers options" do
21
+ assert_equal 4, Accounting.negative_numbers_set.size
22
+ [:black, :black_parenth, :red, :red_parenth].each do |a|
23
+ assert Accounting.negative_numbers_set.include?(a)
24
24
  end
25
+ end
25
26
 
26
- should "set default values" do
27
- assert_equal 2, subject.decimal_places
28
- assert_equal :dollar, subject.symbol
29
- assert_equal true, subject.comma_separator
30
- assert_equal :black, subject.negative_numbers
31
- end
27
+ should "set default values" do
28
+ assert_equal 2, subject.decimal_places
29
+ assert_equal :dollar, subject.symbol
30
+ assert_equal true, subject.comma_separator
31
+ assert_equal :black, subject.negative_numbers
32
+ end
32
33
 
33
- should "only allow Fixnum decimal places between 0 and 30" do
34
- assert_raises ArgumentError do
35
- Accounting.new({:decimal_places => -1})
36
- end
37
- assert_raises ArgumentError do
38
- Accounting.new({:decimal_places => 31})
39
- end
40
- assert_raises ArgumentError do
41
- Accounting.new({:decimal_places => 'poo'})
42
- end
43
- assert_nothing_raised do
44
- Accounting.new({:decimal_places => 1})
45
- end
34
+ should "only allow Fixnum decimal places between 0 and 30" do
35
+ assert_raises ArgumentError do
36
+ Accounting.new({:decimal_places => -1})
46
37
  end
47
-
48
- should "generate decimal place style strings" do
49
- assert_equal "0", Accounting.new({
50
- :decimal_places => 0,
51
- :comma_separator => false,
52
- :symbol => :none
53
- }).style
54
- (1..5).each do |n|
55
- assert_equal "0.#{'0'*n}", Accounting.new({
56
- :decimal_places => n,
57
- :comma_separator => false,
58
- :symbol => :none
59
- }).style
60
- end
38
+ assert_raises ArgumentError do
39
+ Accounting.new({:decimal_places => 31})
61
40
  end
62
-
63
- should "generate comma separator style strings" do
64
- assert_equal "0", Accounting.new({
65
- :comma_separator => false,
66
- :decimal_places => 0,
67
- :symbol => :none
68
- }).style
69
- assert_equal "#,##0", Accounting.new({
70
- :comma_separator => true,
71
- :decimal_places => 0,
72
- :symbol => :none
73
- }).style
41
+ assert_raises ArgumentError do
42
+ Accounting.new({:decimal_places => 'poo'})
74
43
  end
75
-
76
- should "generate parenth negative numbers style strings" do
77
- assert_equal "0", Accounting.new({
78
- :negative_numbers => :black,
79
- :decimal_places => 0,
80
- :comma_separator => false,
81
- :symbol => :none
82
- }).style
83
- assert_equal "0_);\(0\)", Accounting.new({
84
- :negative_numbers => :black_parenth,
85
- :decimal_places => 0,
86
- :comma_separator => false,
87
- :symbol => :none
88
- }).style
44
+ assert_nothing_raised do
45
+ Accounting.new({:decimal_places => 1})
89
46
  end
47
+ end
90
48
 
91
- should "generate red negative numbers style strings" do
92
- assert_equal "0;[Red]0", Accounting.new({
93
- :negative_numbers => :red,
94
- :decimal_places => 0,
95
- :comma_separator => false,
96
- :symbol => :none
97
- }).style
98
- assert_equal "0_);[Red]\(0\)", Accounting.new({
99
- :negative_numbers => :red_parenth,
100
- :decimal_places => 0,
49
+ should "generate decimal place style strings" do
50
+ assert_equal "0", Accounting.new({
51
+ :decimal_places => 0,
52
+ :comma_separator => false,
53
+ :symbol => :none
54
+ }).style
55
+ (1..5).each do |n|
56
+ assert_equal "0.#{'0'*n}", Accounting.new({
57
+ :decimal_places => n,
101
58
  :comma_separator => false,
102
59
  :symbol => :none
103
60
  }).style
104
61
  end
62
+ end
105
63
 
106
- should "generate symbol style strings" do
107
- assert_equal "0", Accounting.new({
108
- :decimal_places => 0,
109
- :comma_separator => false,
110
- :symbol => :none
111
- }).style
112
- assert_equal "\"$\"* 0", Accounting.new({
113
- :decimal_places => 0,
114
- :comma_separator => false,
115
- :symbol => :dollar
116
- }).style
117
- assert_equal "[$€-2]\ * 0", Accounting.new({
118
- :decimal_places => 0,
119
- :comma_separator => false,
120
- :symbol => :euro
121
- }).style
122
- end
64
+ should "generate comma separator style strings" do
65
+ assert_equal "0", Accounting.new({
66
+ :comma_separator => false,
67
+ :decimal_places => 0,
68
+ :symbol => :none
69
+ }).style
70
+ assert_equal "#,##0", Accounting.new({
71
+ :comma_separator => true,
72
+ :decimal_places => 0,
73
+ :symbol => :none
74
+ }).style
75
+ end
123
76
 
124
- should "generate complex style string" do
125
- assert_equal("\"$\"* 0.00_);\(\"$\"* 0.00\)", Accounting.new({
126
- :symbol => :dollar,
127
- :decimal_places => 2,
128
- :negative_numbers => :black_parenth,
129
- :comma_separator => false
130
- }).style)
131
- assert_equal("[$€-2]\ * #,##0.0000_);[Red]\([$€-2]\ * #,##0.0000\)", Accounting.new({
132
- :symbol => :euro,
133
- :decimal_places => 4,
134
- :negative_numbers => :red_parenth,
135
- :comma_separator => true
136
- }).style)
137
- end
77
+ should "generate parenth negative numbers style strings" do
78
+ assert_equal "0", Accounting.new({
79
+ :negative_numbers => :black,
80
+ :decimal_places => 0,
81
+ :comma_separator => false,
82
+ :symbol => :none
83
+ }).style
84
+ assert_equal "0_);\(0\)", Accounting.new({
85
+ :negative_numbers => :black_parenth,
86
+ :decimal_places => 0,
87
+ :comma_separator => false,
88
+ :symbol => :none
89
+ }).style
90
+ end
138
91
 
139
- should "provide unique format keys" do
140
- assert_equal("accounting_dollar_2_nocomma_blackparenth", Accounting.new({
141
- :decimal_places => 2,
142
- :negative_numbers => :black_parenth,
143
- :comma_separator => false
144
- }).key)
145
- assert_equal("accounting_none_4_comma_redparenth", Accounting.new({
146
- :symbol => :none,
147
- :decimal_places => 4,
148
- :negative_numbers => :red_parenth,
149
- :comma_separator => true
150
- }).key)
151
- end
92
+ should "generate red negative numbers style strings" do
93
+ assert_equal "0;[Red]0", Accounting.new({
94
+ :negative_numbers => :red,
95
+ :decimal_places => 0,
96
+ :comma_separator => false,
97
+ :symbol => :none
98
+ }).style
99
+ assert_equal "0_);[Red]\(0\)", Accounting.new({
100
+ :negative_numbers => :red_parenth,
101
+ :decimal_places => 0,
102
+ :comma_separator => false,
103
+ :symbol => :none
104
+ }).style
105
+ end
152
106
 
107
+ should "generate symbol style strings" do
108
+ assert_equal "0", Accounting.new({
109
+ :decimal_places => 0,
110
+ :comma_separator => false,
111
+ :symbol => :none
112
+ }).style
113
+ assert_equal "\"$\"* 0", Accounting.new({
114
+ :decimal_places => 0,
115
+ :comma_separator => false,
116
+ :symbol => :dollar
117
+ }).style
118
+ end
153
119
 
120
+ should "generate complex style string" do
121
+ assert_equal("\"$\"* 0.00_);\(\"$\"* 0.00\)", Accounting.new({
122
+ :symbol => :dollar,
123
+ :decimal_places => 2,
124
+ :negative_numbers => :black_parenth,
125
+ :comma_separator => false
126
+ }).style)
127
+ end
154
128
 
129
+ should "provide unique format keys" do
130
+ assert_equal("accounting_dollar_2_nocomma_blackparenth", Accounting.new({
131
+ :decimal_places => 2,
132
+ :negative_numbers => :black_parenth,
133
+ :comma_separator => false
134
+ }).key)
135
+ assert_equal("accounting_none_4_comma_redparenth", Accounting.new({
136
+ :symbol => :none,
137
+ :decimal_places => 4,
138
+ :negative_numbers => :red_parenth,
139
+ :comma_separator => true
140
+ }).key)
155
141
  end
142
+
156
143
  end
157
144
 
158
145
  end
@@ -1,158 +1,145 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/currency'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class CurrencyTest < Test::Unit::TestCase
7
- context "Currency format" do
8
- subject { Currency.new }
6
+ class CurrencyTest < Assert::Context
7
+ desc "Currency format"
8
+ before { @f = Currency.new }
9
+ subject { @f }
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 symbol options" do
13
- assert_equal 3, Currency.symbol_set.size
14
- [:none, :dollar, :euro].each do |a|
15
- assert Currency.symbol_set.include?(a)
16
- end
13
+ should "provide symbol options" do
14
+ assert_equal 3, Currency.symbol_set.size
15
+ [:none, :dollar, :euro].each do |a|
16
+ assert Currency.symbol_set.include?(a)
17
17
  end
18
+ end
18
19
 
19
- should "provide negative numbers options" do
20
- assert_equal 4, Currency.negative_numbers_set.size
21
- [:black, :black_parenth, :red, :red_parenth].each do |a|
22
- assert Currency.negative_numbers_set.include?(a)
23
- end
20
+ should "provide negative numbers options" do
21
+ assert_equal 4, Currency.negative_numbers_set.size
22
+ [:black, :black_parenth, :red, :red_parenth].each do |a|
23
+ assert Currency.negative_numbers_set.include?(a)
24
24
  end
25
+ end
25
26
 
26
- should "set default values" do
27
- assert_equal 2, subject.decimal_places
28
- assert_equal :dollar, subject.symbol
29
- assert_equal true, subject.comma_separator
30
- assert_equal :black, subject.negative_numbers
31
- end
27
+ should "set default values" do
28
+ assert_equal 2, subject.decimal_places
29
+ assert_equal :dollar, subject.symbol
30
+ assert_equal true, subject.comma_separator
31
+ assert_equal :black, subject.negative_numbers
32
+ end
32
33
 
33
- should "only allow Fixnum decimal places between 0 and 30" do
34
- assert_raises ArgumentError do
35
- Currency.new({:decimal_places => -1})
36
- end
37
- assert_raises ArgumentError do
38
- Currency.new({:decimal_places => 31})
39
- end
40
- assert_raises ArgumentError do
41
- Currency.new({:decimal_places => 'poo'})
42
- end
43
- assert_nothing_raised do
44
- Currency.new({:decimal_places => 1})
45
- end
34
+ should "only allow Fixnum decimal places between 0 and 30" do
35
+ assert_raises ArgumentError do
36
+ Currency.new({:decimal_places => -1})
46
37
  end
47
-
48
- should "generate decimal place style strings" do
49
- assert_equal "0", Currency.new({
50
- :decimal_places => 0,
51
- :comma_separator => false,
52
- :symbol => :none
53
- }).style
54
- (1..5).each do |n|
55
- assert_equal "0.#{'0'*n}", Currency.new({
56
- :decimal_places => n,
57
- :comma_separator => false,
58
- :symbol => :none
59
- }).style
60
- end
38
+ assert_raises ArgumentError do
39
+ Currency.new({:decimal_places => 31})
61
40
  end
62
-
63
- should "generate comma separator style strings" do
64
- assert_equal "0", Currency.new({
65
- :comma_separator => false,
66
- :decimal_places => 0,
67
- :symbol => :none
68
- }).style
69
- assert_equal "#,##0", Currency.new({
70
- :comma_separator => true,
71
- :decimal_places => 0,
72
- :symbol => :none
73
- }).style
41
+ assert_raises ArgumentError do
42
+ Currency.new({:decimal_places => 'poo'})
74
43
  end
75
-
76
- should "generate parenth negative numbers style strings" do
77
- assert_equal "0", Currency.new({
78
- :negative_numbers => :black,
79
- :decimal_places => 0,
80
- :comma_separator => false,
81
- :symbol => :none
82
- }).style
83
- assert_equal "0_);\(0\)", Currency.new({
84
- :negative_numbers => :black_parenth,
85
- :decimal_places => 0,
86
- :comma_separator => false,
87
- :symbol => :none
88
- }).style
44
+ assert_nothing_raised do
45
+ Currency.new({:decimal_places => 1})
89
46
  end
47
+ end
90
48
 
91
- should "generate red negative numbers style strings" do
92
- assert_equal "0;[Red]0", Currency.new({
93
- :negative_numbers => :red,
94
- :decimal_places => 0,
95
- :comma_separator => false,
96
- :symbol => :none
97
- }).style
98
- assert_equal "0_);[Red]\(0\)", Currency.new({
99
- :negative_numbers => :red_parenth,
100
- :decimal_places => 0,
49
+ should "generate decimal place style strings" do
50
+ assert_equal "0", Currency.new({
51
+ :decimal_places => 0,
52
+ :comma_separator => false,
53
+ :symbol => :none
54
+ }).style
55
+ (1..5).each do |n|
56
+ assert_equal "0.#{'0'*n}", Currency.new({
57
+ :decimal_places => n,
101
58
  :comma_separator => false,
102
59
  :symbol => :none
103
60
  }).style
104
61
  end
62
+ end
105
63
 
106
- should "generate symbol style strings" do
107
- assert_equal "0", Currency.new({
108
- :decimal_places => 0,
109
- :comma_separator => false,
110
- :symbol => :none
111
- }).style
112
- assert_equal "\"$\"0", Currency.new({
113
- :decimal_places => 0,
114
- :comma_separator => false,
115
- :symbol => :dollar
116
- }).style
117
- assert_equal "[$€-2]\ 0", Currency.new({
118
- :decimal_places => 0,
119
- :comma_separator => false,
120
- :symbol => :euro
121
- }).style
122
- end
64
+ should "generate comma separator style strings" do
65
+ assert_equal "0", Currency.new({
66
+ :comma_separator => false,
67
+ :decimal_places => 0,
68
+ :symbol => :none
69
+ }).style
70
+ assert_equal "#,##0", Currency.new({
71
+ :comma_separator => true,
72
+ :decimal_places => 0,
73
+ :symbol => :none
74
+ }).style
75
+ end
123
76
 
124
- should "generate complex style string" do
125
- assert_equal("\"$\"0.00_);\(\"$\"0.00\)", Currency.new({
126
- :symbol => :dollar,
127
- :decimal_places => 2,
128
- :negative_numbers => :black_parenth,
129
- :comma_separator => false
130
- }).style)
131
- assert_equal("[$€-2]\ #,##0.0000_);[Red]\([$€-2]\ #,##0.0000\)", Currency.new({
132
- :symbol => :euro,
133
- :decimal_places => 4,
134
- :negative_numbers => :red_parenth,
135
- :comma_separator => true
136
- }).style)
137
- end
77
+ should "generate parenth negative numbers style strings" do
78
+ assert_equal "0", Currency.new({
79
+ :negative_numbers => :black,
80
+ :decimal_places => 0,
81
+ :comma_separator => false,
82
+ :symbol => :none
83
+ }).style
84
+ assert_equal "0_);\(0\)", Currency.new({
85
+ :negative_numbers => :black_parenth,
86
+ :decimal_places => 0,
87
+ :comma_separator => false,
88
+ :symbol => :none
89
+ }).style
90
+ end
138
91
 
139
- should "provide unique format keys" do
140
- assert_equal("currency_dollar_2_nocomma_blackparenth", Currency.new({
141
- :decimal_places => 2,
142
- :negative_numbers => :black_parenth,
143
- :comma_separator => false
144
- }).key)
145
- assert_equal("currency_none_4_comma_redparenth", Currency.new({
146
- :symbol => :none,
147
- :decimal_places => 4,
148
- :negative_numbers => :red_parenth,
149
- :comma_separator => true
150
- }).key)
151
- end
92
+ should "generate red negative numbers style strings" do
93
+ assert_equal "0;[Red]0", Currency.new({
94
+ :negative_numbers => :red,
95
+ :decimal_places => 0,
96
+ :comma_separator => false,
97
+ :symbol => :none
98
+ }).style
99
+ assert_equal "0_);[Red]\(0\)", Currency.new({
100
+ :negative_numbers => :red_parenth,
101
+ :decimal_places => 0,
102
+ :comma_separator => false,
103
+ :symbol => :none
104
+ }).style
105
+ end
152
106
 
107
+ should "generate symbol style strings" do
108
+ assert_equal "0", Currency.new({
109
+ :decimal_places => 0,
110
+ :comma_separator => false,
111
+ :symbol => :none
112
+ }).style
113
+ assert_equal "\"$\"0", Currency.new({
114
+ :decimal_places => 0,
115
+ :comma_separator => false,
116
+ :symbol => :dollar
117
+ }).style
118
+ end
153
119
 
120
+ should "generate complex style string" do
121
+ assert_equal("\"$\"0.00_);\(\"$\"0.00\)", Currency.new({
122
+ :symbol => :dollar,
123
+ :decimal_places => 2,
124
+ :negative_numbers => :black_parenth,
125
+ :comma_separator => false
126
+ }).style)
127
+ end
154
128
 
129
+ should "provide unique format keys" do
130
+ assert_equal("currency_dollar_2_nocomma_blackparenth", Currency.new({
131
+ :decimal_places => 2,
132
+ :negative_numbers => :black_parenth,
133
+ :comma_separator => false
134
+ }).key)
135
+ assert_equal("currency_none_4_comma_redparenth", Currency.new({
136
+ :symbol => :none,
137
+ :decimal_places => 4,
138
+ :negative_numbers => :red_parenth,
139
+ :comma_separator => true
140
+ }).key)
155
141
  end
142
+
156
143
  end
157
144
 
158
145
  end
@@ -1,21 +1,21 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/custom'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class CustomTest < Test::Unit::TestCase
7
- context "Custom format" do
8
- should "generate a basic style string and key" do
9
- f = Custom.new '@'
10
- assert_equal "@", f.style
11
- assert_equal "custom_@", f.key
12
- end
6
+ class CustomTest < Assert::Context
7
+ desc "Custom format"
13
8
 
14
- should "generate a more complex style string and key" do
15
- f = Custom.new 'm/d/yy'
16
- assert_equal 'm/d/yy', f.style
17
- assert_equal "custom_m/d/yy", f.key
18
- end
9
+ should "generate a basic style string and key" do
10
+ f = Custom.new '@'
11
+ assert_equal "@", f.style
12
+ assert_equal "custom_@", f.key
13
+ end
14
+
15
+ should "generate a more complex style string and key" do
16
+ f = Custom.new 'm/d/yy'
17
+ assert_equal 'm/d/yy', f.style
18
+ assert_equal "custom_m/d/yy", f.key
19
19
  end
20
20
  end
21
21
 
@@ -1,21 +1,21 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/format/datetime'
3
3
 
4
4
  module Osheet::Format
5
5
 
6
- class DatetimeTest < Test::Unit::TestCase
7
- context "Datetime format" do
8
- should "generate a basic style string and key" do
9
- f = Datetime.new 'mm/dd/yyyy'
10
- assert_equal "mm/dd/yyyy", f.style
11
- assert_equal "datetime_mm/dd/yyyy", f.key
12
- end
6
+ class DatetimeTest < Assert::Context
7
+ desc "Datetime format"
13
8
 
14
- should "generate a more complex style string and key" do
15
- f = Datetime.new 'yy-m'
16
- assert_equal 'yy-m', f.style
17
- assert_equal "datetime_yy-m", f.key
18
- end
9
+ should "generate a basic style string and key" do
10
+ f = Datetime.new 'mm/dd/yyyy'
11
+ assert_equal "mm/dd/yyyy", f.style
12
+ assert_equal "datetime_mm/dd/yyyy", f.key
13
+ end
14
+
15
+ should "generate a more complex style string and key" do
16
+ f = Datetime.new 'yy-m'
17
+ assert_equal 'yy-m', f.style
18
+ assert_equal "datetime_yy-m", f.key
19
19
  end
20
20
  end
21
21