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.
- data/.gitignore +5 -3
- data/Gemfile +2 -0
- data/Gemfile.lock +13 -37
- data/Rakefile +3 -3
- data/lib/osheet/format/numeric.rb +0 -2
- data/lib/osheet/instance.rb +1 -3
- data/lib/osheet/version.rb +2 -2
- data/osheet.gemspec +3 -9
- data/test/cell_test.rb +96 -104
- data/test/column_test.rb +90 -97
- data/test/format/accounting_test.rb +115 -128
- data/test/format/currency_test.rb +115 -128
- data/test/format/custom_test.rb +13 -13
- data/test/format/datetime_test.rb +13 -13
- data/test/format/fraction_test.rb +63 -63
- data/test/format/general_test.rb +11 -11
- data/test/format/number_test.rb +67 -69
- data/test/format/percentage_test.rb +89 -91
- data/test/format/scientific_test.rb +89 -91
- data/test/format/special_test.rb +35 -35
- data/test/format/text_test.rb +9 -9
- data/test/format_test.rb +24 -24
- data/test/helper.rb +42 -47
- data/test/irb.rb +9 -0
- data/test/mixin_test.rb +55 -59
- data/test/osheet_test.rb +7 -10
- data/test/partial_set_test.rb +41 -61
- data/test/partial_test.rb +44 -46
- data/test/row_test.rb +92 -99
- data/test/style_set_test.rb +34 -37
- data/test/style_test.rb +72 -97
- data/test/template_set_test.rb +52 -73
- data/test/template_test.rb +31 -49
- data/test/workbook_test.rb +186 -199
- data/test/worksheet_test.rb +99 -103
- data/test/xmlss_writer/base_test.rb +72 -73
- data/test/xmlss_writer/elements_test.rb +141 -140
- data/test/xmlss_writer/styles_test.rb +197 -208
- metadata +27 -247
- data/.bundle/config +0 -2
- data/test/app_helper.rb +0 -66
- data/test/env.rb +0 -10
- data/test/rails/three/.gitignore +0 -4
- data/test/rails/three/Gemfile +0 -5
- data/test/rails/three/Gemfile.lock +0 -88
- data/test/rails/three/app/controllers/application_controller.rb +0 -3
- data/test/rails/three/app/controllers/things_controller.rb +0 -10
- data/test/rails/three/app/helpers/application_helper.rb +0 -2
- data/test/rails/three/app/views/layouts/application.html.erb +0 -14
- data/test/rails/three/app/views/things/index.xls.osheet +0 -13
- data/test/rails/three/config/application.rb +0 -42
- data/test/rails/three/config/boot.rb +0 -13
- data/test/rails/three/config/database.yml +0 -22
- data/test/rails/three/config/environment.rb +0 -5
- data/test/rails/three/config/environments/development.rb +0 -26
- data/test/rails/three/config/environments/production.rb +0 -49
- data/test/rails/three/config/environments/test.rb +0 -35
- data/test/rails/three/config/initializers/app.rb +0 -0
- data/test/rails/three/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/three/config/initializers/inflections.rb +0 -10
- data/test/rails/three/config/initializers/mime_types.rb +0 -5
- data/test/rails/three/config/initializers/secret_token.rb +0 -7
- data/test/rails/three/config/initializers/session_store.rb +0 -8
- data/test/rails/three/config/locales/en.yml +0 -5
- data/test/rails/three/config/routes.rb +0 -3
- data/test/rails/three/config.ru +0 -4
- data/test/rails/three/db/seeds.rb +0 -7
- data/test/rails/three/doc/README_FOR_APP +0 -2
- data/test/rails/three/lib/tasks/.gitkeep +0 -0
- data/test/rails/three/script/rails +0 -6
- data/test/rails/two/.bundle/config +0 -2
- data/test/rails/two/Booting +0 -0
- data/test/rails/two/Gemfile +0 -5
- data/test/rails/two/Gemfile.lock +0 -45
- data/test/rails/two/Rails +0 -0
- data/test/rails/two/app/controllers/application_controller.rb +0 -20
- data/test/rails/two/app/controllers/things_controller.rb +0 -10
- data/test/rails/two/app/helpers/application_helper.rb +0 -3
- data/test/rails/two/app/views/things/index.xls.osheet +0 -15
- data/test/rails/two/config/boot.rb +0 -128
- data/test/rails/two/config/database.yml +0 -22
- data/test/rails/two/config/environment.rb +0 -41
- data/test/rails/two/config/environments/development.rb +0 -17
- data/test/rails/two/config/environments/production.rb +0 -28
- data/test/rails/two/config/environments/test.rb +0 -28
- data/test/rails/two/config/initializers/app.rb +0 -2
- data/test/rails/two/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/two/config/initializers/cookie_verification_secret.rb +0 -7
- data/test/rails/two/config/initializers/inflections.rb +0 -10
- data/test/rails/two/config/initializers/mime_types.rb +0 -5
- data/test/rails/two/config/initializers/new_rails_defaults.rb +0 -21
- data/test/rails/two/config/initializers/session_store.rb +0 -15
- data/test/rails/two/config/locales/en.yml +0 -5
- data/test/rails/two/config/routes.rb +0 -3
- data/test/rails/two/db/development.sqlite3 +0 -0
- data/test/rails/two/db/seeds.rb +0 -7
- data/test/rails/two/script/about +0 -4
- data/test/rails/two/script/console +0 -3
- data/test/rails/two/script/dbconsole +0 -3
- data/test/rails/two/script/destroy +0 -3
- data/test/rails/two/script/generate +0 -3
- data/test/rails/two/script/performance/benchmarker +0 -3
- data/test/rails/two/script/performance/profiler +0 -3
- data/test/rails/two/script/plugin +0 -3
- data/test/rails/two/script/runner +0 -3
- data/test/rails/two/script/server +0 -3
- data/test/rails/two/tmp/pids/server.pid +0 -1
- data/test/rails_test.rb +0 -38
- data/test/sinatra/app.rb +0 -16
- data/test/sinatra/views/index.osheet +0 -13
- data/test/sinatra_test.rb +0 -19
|
@@ -1,116 +1,114 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/scientific'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class ScientificTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class ScientificTest < Assert::Context
|
|
7
|
+
desc "Scientific format"
|
|
8
|
+
before { @sc = Scientific.new }
|
|
9
|
+
subject { @sc }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
assert_equal "
|
|
79
|
-
:
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
data/test/format/special_test.rb
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/special'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class SpecialTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class SpecialTest < Assert::Context
|
|
7
|
+
desc "Special format"
|
|
8
|
+
before { @sp = Special.new }
|
|
9
|
+
subject { @sp }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
should have_accessors :type
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
data/test/format/text_test.rb
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/text'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class TextTest <
|
|
7
|
-
|
|
8
|
-
|
|
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 "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format'
|
|
3
3
|
|
|
4
4
|
module Osheet
|
|
5
5
|
|
|
6
|
-
class FormatTest <
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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 '
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
-
|
|
22
|
+
style('.title', '.header') {
|
|
23
|
+
font :bold
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
klass = klass.new(wkbk)
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
51
|
+
should have_instance_methods :style_class
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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 "
|
|
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
|
-
|
|
84
|
-
|
|
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
data/test/mixin_test.rb
CHANGED
|
@@ -1,90 +1,86 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require "test/mixins"
|
|
3
3
|
|
|
4
4
|
module Osheet
|
|
5
5
|
|
|
6
|
-
class MixinBaseTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class MixinBaseTest < Assert::Context
|
|
7
|
+
desc "Osheet::Mixin thing"
|
|
8
|
+
subject { DefaultMixin }
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
should have_readers :styles, :templates, :partials
|
|
11
|
+
should have_instance_methods :style, :template, :partial
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 <
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
class MixinStyleTest < Assert::Context
|
|
21
|
+
desc "that defines styles"
|
|
22
|
+
subject { StyledMixin }
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 <
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
class MixinTemplateTest < Assert::Context
|
|
34
|
+
desc "that defines templates"
|
|
35
|
+
subject { TemplatedMixin }
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 <
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
class MixinPartialTest < Assert::Context
|
|
45
|
+
desc "that defines partials"
|
|
46
|
+
subject { PartialedMixin }
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 <
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
63
|
+
end
|
|
64
|
+
subject { @workbook }
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|