osheet 1.0.0.rc.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -6
- data/Gemfile +3 -4
- data/LICENSE.txt +22 -0
- data/README.md +129 -0
- data/Rakefile +1 -7
- data/lib/osheet/cell.rb +0 -1
- data/lib/osheet/column.rb +3 -2
- data/lib/osheet/format.rb +9 -9
- data/lib/osheet/format/accounting.rb +0 -1
- data/lib/osheet/format/currency.rb +1 -1
- data/lib/osheet/format/custom.rb +0 -1
- data/lib/osheet/format/datetime.rb +0 -1
- data/lib/osheet/format/fraction.rb +0 -1
- data/lib/osheet/format/general.rb +2 -2
- data/lib/osheet/format/number.rb +0 -1
- data/lib/osheet/format/numeric.rb +2 -1
- data/lib/osheet/format/percentage.rb +2 -1
- data/lib/osheet/format/scientific.rb +2 -1
- data/lib/osheet/format/special.rb +0 -1
- data/lib/osheet/format/text.rb +0 -1
- data/lib/osheet/mixin.rb +1 -0
- data/lib/osheet/row.rb +0 -1
- data/lib/osheet/style.rb +1 -0
- data/lib/osheet/styled_element.rb +1 -0
- data/lib/osheet/version.rb +1 -1
- data/lib/osheet/workbook.rb +0 -4
- data/lib/osheet/workbook_element.rb +0 -10
- data/osheet.gemspec +18 -16
- data/test/helper.rb +6 -2
- data/test/{fixtures → support}/mixins.rb +0 -0
- data/test/{fixtures → support}/test_writer.rb +0 -0
- data/test/{cell_test.rb → unit/cell_tests.rb} +15 -12
- data/test/{column_test.rb → unit/column_tests.rb} +10 -9
- data/test/{format/accounting_test.rb → unit/format/accounting_tests.rb} +35 -26
- data/test/{format/currency_test.rb → unit/format/currency_tests.rb} +35 -26
- data/test/{format/custom_test.rb → unit/format/custom_tests.rb} +6 -5
- data/test/{format/datetime_test.rb → unit/format/datetime_tests.rb} +6 -5
- data/test/{format/fraction_test.rb → unit/format/fraction_tests.rb} +16 -16
- data/test/{format/general_test.rb → unit/format/general_tests.rb} +5 -5
- data/test/unit/format/number_tests.rb +96 -0
- data/test/{format/percentage_test.rb → unit/format/percentage_tests.rb} +32 -23
- data/test/{format/scientific_test.rb → unit/format/scientific_tests.rb} +31 -23
- data/test/{format/special_test.rb → unit/format/special_tests.rb} +11 -11
- data/test/{format/text_test.rb → unit/format/text_tests.rb} +4 -4
- data/test/{format_test.rb → unit/format_tests.rb} +8 -7
- data/test/{mixin_test.rb → unit/mixin_tests.rb} +11 -10
- data/test/{partial_test.rb → unit/partial_tests.rb} +13 -10
- data/test/{row_test.rb → unit/row_tests.rb} +11 -10
- data/test/{style_test.rb → unit/style_tests.rb} +13 -14
- data/test/{template_test.rb → unit/template_tests.rb} +15 -12
- data/test/{workbook_element_test.rb → unit/workbook_element_tests.rb} +48 -54
- data/test/{workbook_test.rb → unit/workbook_tests.rb} +34 -30
- data/test/{worksheet_test.rb → unit/worksheet_tests.rb} +13 -13
- metadata +70 -76
- data/Gemfile.lock +0 -27
- data/README.rdoc +0 -133
- data/test/format/number_test.rb +0 -91
- data/test/irb.rb +0 -9
@@ -1,19 +1,19 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/special'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Special
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Special
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Special"
|
8
|
+
before{ @sp = Osheet::Format::Special.new }
|
9
|
+
subject{ @sp }
|
10
10
|
|
11
11
|
should have_accessors :type
|
12
12
|
|
13
13
|
should "provide options for type" do
|
14
|
-
assert_equal 4, Special.type_set.size
|
14
|
+
assert_equal 4, Osheet::Format::Special.type_set.size
|
15
15
|
[ :zip_code, :zip_code_plus_4, :phone_number, :social_security_number].each do |a|
|
16
|
-
assert Special.type_set.include?(a)
|
16
|
+
assert Osheet::Format::Special.type_set.include?(a)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -23,25 +23,25 @@ module Osheet::Format
|
|
23
23
|
end
|
24
24
|
|
25
25
|
should "generate a zip_code type style strings and key" do
|
26
|
-
f = Special.new(:type => :zip_code)
|
26
|
+
f = Osheet::Format::Special.new(:type => :zip_code)
|
27
27
|
assert_equal "00000", f.style
|
28
28
|
assert_equal "special_zipcode", f.key
|
29
29
|
end
|
30
30
|
|
31
31
|
should "generate a zip_code_plus_4 type style strings and key" do
|
32
|
-
f = Special.new(:type => :zip_code_plus_4)
|
32
|
+
f = Osheet::Format::Special.new(:type => :zip_code_plus_4)
|
33
33
|
assert_equal "00000-0000", f.style
|
34
34
|
assert_equal "special_zipcodeplus4", f.key
|
35
35
|
end
|
36
36
|
|
37
37
|
should "generate a phone_number type style strings and key" do
|
38
|
-
f = Special.new(:type => :phone_number)
|
38
|
+
f = Osheet::Format::Special.new(:type => :phone_number)
|
39
39
|
assert_equal "[<=9999999]###-####;(###) ###-####", f.style
|
40
40
|
assert_equal "special_phonenumber", f.key
|
41
41
|
end
|
42
42
|
|
43
43
|
should "generate a social_security_number type style strings and key" do
|
44
|
-
f = Special.new(:type => :social_security_number)
|
44
|
+
f = Osheet::Format::Special.new(:type => :social_security_number)
|
45
45
|
assert_equal "000-00-0000", f.style
|
46
46
|
assert_equal "special_socialsecuritynumber", f.key
|
47
47
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/text'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Text
|
5
5
|
|
6
|
-
class
|
6
|
+
class UnitTests < Assert::Context
|
7
7
|
desc "Text format"
|
8
|
-
before
|
9
|
-
subject
|
8
|
+
before{ @txt = Osheet::Format::Text.new }
|
9
|
+
subject{ @txt }
|
10
10
|
|
11
11
|
should "generate a style strings and key" do
|
12
12
|
assert_equal "@", subject.style
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format'
|
3
3
|
|
4
|
-
module Osheet
|
4
|
+
module Osheet::Format
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format"
|
8
8
|
before do
|
9
|
-
@f = Format.new(:number, {
|
9
|
+
@f = Osheet::Format.new(:number, {
|
10
10
|
:decimal_places => 4,
|
11
11
|
:comma_separator => true,
|
12
12
|
:negative_numbers => :black_parenth
|
@@ -15,7 +15,7 @@ module Osheet
|
|
15
15
|
subject { @f }
|
16
16
|
|
17
17
|
should "build format class instances" do
|
18
|
-
assert_kind_of Format::Number, subject
|
18
|
+
assert_kind_of Osheet::Format::Number, subject
|
19
19
|
assert_equal 4, subject.decimal_places
|
20
20
|
assert_equal true, subject.comma_separator
|
21
21
|
assert_equal 'black_parenth', subject.negative_numbers
|
@@ -23,10 +23,11 @@ module Osheet
|
|
23
23
|
|
24
24
|
should "error for invalid format types" do
|
25
25
|
assert_raises ArgumentError do
|
26
|
-
Format.new(:awesome, {})
|
26
|
+
Osheet::Format.new(:awesome, {})
|
27
27
|
end
|
28
|
+
|
28
29
|
assert_nothing_raised do
|
29
|
-
Format.new(:general)
|
30
|
+
Osheet::Format.new(:general)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
require
|
3
|
-
require 'osheet/workbook'
|
2
|
+
require 'osheet/mixin'
|
4
3
|
|
5
|
-
|
4
|
+
require "test/support/mixins"
|
6
5
|
|
7
|
-
|
6
|
+
module Osheet::Mixin
|
7
|
+
|
8
|
+
class UnitTests < Assert::Context
|
8
9
|
desc "a mixin"
|
9
10
|
subject { DefaultMixin }
|
10
11
|
|
@@ -18,11 +19,11 @@ module Osheet
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
class MixinArgsTests <
|
22
|
+
class MixinArgsTests < UnitTests
|
22
23
|
desc "args class"
|
23
24
|
before do
|
24
25
|
@build_block = Proc.new {}
|
25
|
-
@ma = Mixin::Args.new('some', 'args', 'here', &@build_block)
|
26
|
+
@ma = Osheet::Mixin::Args.new('some', 'args', 'here', &@build_block)
|
26
27
|
end
|
27
28
|
subject { @ma }
|
28
29
|
|
@@ -37,7 +38,7 @@ module Osheet
|
|
37
38
|
end
|
38
39
|
|
39
40
|
should "default with empty args and an empty Proc build" do
|
40
|
-
default = Mixin::Args.new
|
41
|
+
default = Osheet::Mixin::Args.new
|
41
42
|
|
42
43
|
assert_empty default.args
|
43
44
|
assert_kind_of Proc, default.build
|
@@ -51,7 +52,7 @@ module Osheet
|
|
51
52
|
|
52
53
|
should "have it's styles defined" do
|
53
54
|
assert_equal 2, subject.styles.size
|
54
|
-
assert_kind_of Mixin::Args, subject.styles.first
|
55
|
+
assert_kind_of Osheet::Mixin::Args, subject.styles.first
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -62,7 +63,7 @@ module Osheet
|
|
62
63
|
should "have it's templates defined" do
|
63
64
|
assert subject.templates
|
64
65
|
assert_equal 3, subject.templates.size
|
65
|
-
assert_kind_of Mixin::Args, subject.templates.first
|
66
|
+
assert_kind_of Osheet::Mixin::Args, subject.templates.first
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
@@ -73,7 +74,7 @@ module Osheet
|
|
73
74
|
should "have it's partials defined" do
|
74
75
|
assert subject.partials
|
75
76
|
assert_equal 2, subject.partials.size
|
76
|
-
assert_kind_of Mixin::Args, subject.partials.first
|
77
|
+
assert_kind_of Osheet::Mixin::Args, subject.partials.first
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require "osheet/partial"
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class Osheet::Partial
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Partial"
|
8
|
+
before{ @p = Osheet::Partial.new(:thing) {} }
|
9
|
+
subject{ @p }
|
10
10
|
|
11
11
|
should "be a Proc" do
|
12
12
|
assert_kind_of ::Proc, subject
|
@@ -23,16 +23,19 @@ module Osheet
|
|
23
23
|
|
24
24
|
should "verify the name argument" do
|
25
25
|
assert_raises ArgumentError do
|
26
|
-
Partial.new([]) {}
|
26
|
+
Osheet::Partial.new([]) {}
|
27
27
|
end
|
28
|
+
|
28
29
|
assert_raises ArgumentError do
|
29
|
-
Partial.new(1) {}
|
30
|
+
Osheet::Partial.new(1) {}
|
30
31
|
end
|
32
|
+
|
31
33
|
assert_nothing_raised do
|
32
|
-
Partial.new(:poo) {}
|
34
|
+
Osheet::Partial.new(:poo) {}
|
33
35
|
end
|
36
|
+
|
34
37
|
assert_nothing_raised do
|
35
|
-
Partial.new('poo') {}
|
38
|
+
Osheet::Partial.new('poo') {}
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require "assert"
|
2
|
+
require 'osheet/row'
|
2
3
|
|
3
4
|
require 'osheet/cell'
|
4
|
-
require 'osheet/
|
5
|
+
require 'osheet/format/general'
|
5
6
|
|
6
|
-
|
7
|
+
class Osheet::Row
|
7
8
|
|
8
|
-
class
|
9
|
-
desc "
|
10
|
-
before { @rw = Row.new }
|
9
|
+
class UnitTests < Assert::Context
|
10
|
+
desc "Osheet::Row"
|
11
|
+
before { @rw = Osheet::Row.new }
|
11
12
|
subject { @rw }
|
12
13
|
|
13
14
|
should be_a_styled_element
|
@@ -25,7 +26,7 @@ module Osheet
|
|
25
26
|
assert !subject.autofit?
|
26
27
|
assert_equal false, subject.hidden
|
27
28
|
assert !subject.hidden?
|
28
|
-
assert_kind_of Format::General, subject.format
|
29
|
+
assert_kind_of Osheet::Format::General, subject.format
|
29
30
|
end
|
30
31
|
|
31
32
|
should "set it's width" do
|
@@ -38,11 +39,11 @@ module Osheet
|
|
38
39
|
subject.height(nil)
|
39
40
|
assert_equal 180, subject.height
|
40
41
|
|
41
|
-
assert_equal 200, Row.new(200).height
|
42
|
+
assert_equal 200, Osheet::Row.new(200).height
|
42
43
|
end
|
43
44
|
|
44
45
|
should "cast autofit and hidden to bool" do
|
45
|
-
row = Row.new
|
46
|
+
row = Osheet::Row.new
|
46
47
|
row.autofit :true
|
47
48
|
row.hidden 'false'
|
48
49
|
|
@@ -52,10 +53,10 @@ module Osheet
|
|
52
53
|
|
53
54
|
end
|
54
55
|
|
55
|
-
class RowCellTests <
|
56
|
+
class RowCellTests < UnitTests
|
56
57
|
desc "with cells"
|
57
58
|
before {
|
58
|
-
@cell = Cell.new
|
59
|
+
@cell = Osheet::Cell.new
|
59
60
|
@rw.cell(@cell)
|
60
61
|
}
|
61
62
|
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require "osheet/style"
|
4
3
|
|
5
|
-
|
4
|
+
class Osheet::Style
|
6
5
|
|
7
|
-
class
|
8
|
-
desc "
|
9
|
-
before { @st = Style.new('.test') }
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Style"
|
8
|
+
before { @st = Osheet::Style.new('.test') }
|
10
9
|
subject { @st }
|
11
10
|
|
12
11
|
should have_reader :selectors, :build
|
@@ -28,7 +27,7 @@ module Osheet
|
|
28
27
|
should "complain about bad selectors" do
|
29
28
|
['poo', '#poo', 'poo poo', 'poo > poo', :poo, 123].each do |s|
|
30
29
|
assert_raises ArgumentError do
|
31
|
-
Style.new(s)
|
30
|
+
Osheet::Style.new(s)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -36,7 +35,7 @@ module Osheet
|
|
36
35
|
should "not complain about good selectors" do
|
37
36
|
['.poo', '.poo.poo', '.poo-poo', '.poo_poo'].each do |s|
|
38
37
|
assert_nothing_raised do
|
39
|
-
Style.new(s)
|
38
|
+
Osheet::Style.new(s)
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -60,13 +59,13 @@ module Osheet
|
|
60
59
|
end
|
61
60
|
|
62
61
|
should "match on style class strings" do
|
63
|
-
a
|
64
|
-
at
|
65
|
-
b
|
66
|
-
bt
|
67
|
-
a_b = Style.new('.awesome', '.boring') {}
|
68
|
-
t
|
69
|
-
s
|
62
|
+
a = Osheet::Style.new('.awesome') {}
|
63
|
+
at = Osheet::Style.new('.awesome.thing') {}
|
64
|
+
b = Osheet::Style.new('.boring') {}
|
65
|
+
bt = Osheet::Style.new('.boring.thing') {}
|
66
|
+
a_b = Osheet::Style.new('.awesome', '.boring') {}
|
67
|
+
t = Osheet::Style.new('.thing') {}
|
68
|
+
s = Osheet::Style.new('.stupid') {}
|
70
69
|
|
71
70
|
{ 'awesome' => [a, a_b],
|
72
71
|
'boring' => [b, a_b],
|
@@ -1,22 +1,23 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require "osheet/template"
|
4
3
|
|
5
|
-
|
4
|
+
require 'osheet/partial'
|
5
|
+
|
6
|
+
class Osheet::Template
|
6
7
|
|
7
|
-
class
|
8
|
-
desc "
|
8
|
+
class UnitTests < Assert::Context
|
9
|
+
desc "Osheet::Template"
|
9
10
|
before do
|
10
|
-
@tmpl = Template.new('column', :thing) {}
|
11
|
+
@tmpl = Osheet::Template.new('column', :thing) {}
|
11
12
|
end
|
12
13
|
subject { @tmpl }
|
13
14
|
|
14
15
|
should "define what elements it is valid for" do
|
15
|
-
assert_equal ['worksheet', 'column', 'row', 'cell'], Template::ELEMENTS
|
16
|
+
assert_equal ['worksheet', 'column', 'row', 'cell'], Osheet::Template::ELEMENTS
|
16
17
|
end
|
17
18
|
|
18
19
|
should "be a Partial" do
|
19
|
-
assert_kind_of Partial, subject
|
20
|
+
assert_kind_of Osheet::Partial, subject
|
20
21
|
end
|
21
22
|
|
22
23
|
should "convert the element ars to string and store off" do
|
@@ -25,19 +26,21 @@ module Osheet
|
|
25
26
|
|
26
27
|
end
|
27
28
|
|
28
|
-
class TemplateElementTest <
|
29
|
+
class TemplateElementTest < UnitTests
|
29
30
|
desc "a template"
|
30
31
|
|
31
32
|
should "verify the element argument" do
|
32
33
|
assert_raises ArgumentError do
|
33
|
-
Template.new({}, :poo) {}
|
34
|
+
Osheet::Template.new({}, :poo) {}
|
34
35
|
end
|
36
|
+
|
35
37
|
assert_raises ArgumentError do
|
36
|
-
Template.new('workbook', :poo) {}
|
38
|
+
Osheet::Template.new('workbook', :poo) {}
|
37
39
|
end
|
38
|
-
|
40
|
+
|
41
|
+
Osheet::Template::ELEMENTS.each do |elem|
|
39
42
|
assert_nothing_raised do
|
40
|
-
Template.new(elem, :poo) {}
|
43
|
+
Osheet::Template.new(elem, :poo) {}
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require 'osheet/workbook_element'
|
4
3
|
|
5
|
-
|
4
|
+
require 'osheet/partial'
|
5
|
+
require 'osheet/template'
|
6
|
+
require 'osheet/style'
|
7
|
+
require 'osheet/worksheet'
|
6
8
|
|
9
|
+
class Osheet::WorkbookElement
|
7
10
|
|
8
|
-
class
|
9
|
-
desc "
|
11
|
+
class UnitTests < Assert::Context
|
12
|
+
desc "Osheet::WorkbookElement"
|
10
13
|
before do
|
11
|
-
@wd = WorkbookElement.new
|
14
|
+
@wd = Osheet::WorkbookElement.new
|
12
15
|
end
|
13
|
-
subject
|
16
|
+
subject{ @wd }
|
14
17
|
|
15
18
|
should have_reader :title
|
16
19
|
should have_readers :templates, :partials, :styles, :worksheets
|
@@ -18,19 +21,17 @@ module Osheet
|
|
18
21
|
|
19
22
|
should "set it's defaults" do
|
20
23
|
assert_nil subject.title
|
21
|
-
assert_equal WorkbookElement::TemplateSet.new, subject.templates
|
22
|
-
assert_equal WorkbookElement::PartialSet.new, subject.partials
|
23
|
-
assert_equal WorkbookElement::StyleSet.new, subject.styles
|
24
|
-
assert_equal WorkbookElement::WorksheetSet.new, subject.worksheets
|
24
|
+
assert_equal Osheet::WorkbookElement::TemplateSet.new, subject.templates
|
25
|
+
assert_equal Osheet::WorkbookElement::PartialSet.new, subject.partials
|
26
|
+
assert_equal Osheet::WorkbookElement::StyleSet.new, subject.styles
|
27
|
+
assert_equal Osheet::WorkbookElement::WorksheetSet.new, subject.worksheets
|
25
28
|
end
|
26
29
|
|
27
30
|
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
32
|
class PartialSetTests < Assert::Context
|
32
33
|
desc "a PartialSet"
|
33
|
-
before { @ps = WorkbookElement::PartialSet.new }
|
34
|
+
before { @ps = Osheet::WorkbookElement::PartialSet.new }
|
34
35
|
subject { @ps }
|
35
36
|
|
36
37
|
should "be a Hash" do
|
@@ -45,7 +46,7 @@ module Osheet
|
|
45
46
|
subject.send(:verify, {})
|
46
47
|
end
|
47
48
|
assert_nothing_raised do
|
48
|
-
subject.send(:verify, Partial.new(:poo) {})
|
49
|
+
subject.send(:verify, Osheet::Partial.new(:poo) {})
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -54,30 +55,30 @@ module Osheet
|
|
54
55
|
end
|
55
56
|
|
56
57
|
should "key on partial objs" do
|
57
|
-
assert_equal 'poo', subject.send(:partial_key, Partial.new(:poo) {})
|
58
|
+
assert_equal 'poo', subject.send(:partial_key, Osheet::Partial.new(:poo) {})
|
58
59
|
end
|
59
60
|
|
60
61
|
should "init the key in the set when verifying" do
|
61
|
-
key = subject.send(:verify, Partial.new(:thing) {})
|
62
|
+
key = subject.send(:verify, Osheet::Partial.new(:thing) {})
|
62
63
|
assert_equal 'thing', key
|
63
64
|
assert_equal({'thing' => nil}, subject)
|
64
65
|
end
|
65
66
|
|
66
67
|
should "push partials onto the set" do
|
67
68
|
assert_nothing_raised do
|
68
|
-
subject << Partial.new(:poo) {}
|
69
|
-
subject << Partial.new(:not_poo) {}
|
70
|
-
subject << Partial.new(:awesome) {}
|
71
|
-
subject << Partial.new(:poo) {}
|
69
|
+
subject << Osheet::Partial.new(:poo) {}
|
70
|
+
subject << Osheet::Partial.new(:not_poo) {}
|
71
|
+
subject << Osheet::Partial.new(:awesome) {}
|
72
|
+
subject << Osheet::Partial.new(:poo) {}
|
72
73
|
end
|
73
74
|
|
74
75
|
assert_equal 3, subject.keys.size
|
75
76
|
assert subject["poo"]
|
76
|
-
assert_kind_of Partial, subject["poo"]
|
77
|
+
assert_kind_of Osheet::Partial, subject["poo"]
|
77
78
|
end
|
78
79
|
|
79
80
|
should "lookup a partial by name" do
|
80
|
-
p = Partial.new(:poo) {}
|
81
|
+
p = Osheet::Partial.new(:poo) {}
|
81
82
|
subject << p
|
82
83
|
assert_equal p, subject.get(:poo)
|
83
84
|
assert_equal p, subject.get('poo')
|
@@ -86,15 +87,13 @@ module Osheet
|
|
86
87
|
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
90
|
class TemplateSetTests < Assert::Context
|
92
91
|
desc "a TemplateSet"
|
93
|
-
before { @set = WorkbookElement::TemplateSet.new }
|
92
|
+
before { @set = Osheet::WorkbookElement::TemplateSet.new }
|
94
93
|
subject { @set }
|
95
94
|
|
96
95
|
should "be a PartialSet" do
|
97
|
-
assert_kind_of WorkbookElement::PartialSet, subject
|
96
|
+
assert_kind_of Osheet::WorkbookElement::PartialSet, subject
|
98
97
|
end
|
99
98
|
|
100
99
|
should "verify set objs are templates" do
|
@@ -102,7 +101,7 @@ module Osheet
|
|
102
101
|
subject.send(:verify, {})
|
103
102
|
end
|
104
103
|
assert_nothing_raised do
|
105
|
-
subject.send(:verify, Template.new(:row, :poo) {})
|
104
|
+
subject.send(:verify, Osheet::Template.new(:row, :poo) {})
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
@@ -111,11 +110,11 @@ module Osheet
|
|
111
110
|
end
|
112
111
|
|
113
112
|
should "key on templates objs" do
|
114
|
-
assert_equal ['row', 'poo'], subject.send(:template_key, Template.new(:row, :poo) {})
|
113
|
+
assert_equal ['row', 'poo'], subject.send(:template_key, Osheet::Template.new(:row, :poo) {})
|
115
114
|
end
|
116
115
|
|
117
116
|
should "init the key in the set when verifying" do
|
118
|
-
key = subject.send(:verify, Template.new(:row, :poo) {})
|
117
|
+
key = subject.send(:verify, Osheet::Template.new(:row, :poo) {})
|
119
118
|
assert_equal ['row', 'poo'], key
|
120
119
|
assert_equal({
|
121
120
|
key.first => { key.last => nil }
|
@@ -124,29 +123,29 @@ module Osheet
|
|
124
123
|
|
125
124
|
should "push templates onto the set" do
|
126
125
|
assert_nothing_raised do
|
127
|
-
subject << Template.new(:row, :poo) {}
|
128
|
-
subject << Template.new(:row, :not_poo) {}
|
129
|
-
subject << Template.new(:column, :awesome) {}
|
130
|
-
subject << Template.new(:column, :not_awesome) {}
|
126
|
+
subject << Osheet::Template.new(:row, :poo) {}
|
127
|
+
subject << Osheet::Template.new(:row, :not_poo) {}
|
128
|
+
subject << Osheet::Template.new(:column, :awesome) {}
|
129
|
+
subject << Osheet::Template.new(:column, :not_awesome) {}
|
131
130
|
end
|
132
131
|
|
133
132
|
assert_equal 2, subject.keys.size
|
134
133
|
assert subject["row"]
|
135
134
|
assert_equal 2, subject["row"].keys.size
|
136
135
|
assert subject["row"]["poo"]
|
137
|
-
assert_kind_of Template, subject["row"]["poo"]
|
136
|
+
assert_kind_of Osheet::Template, subject["row"]["poo"]
|
138
137
|
assert subject["row"]["not_poo"]
|
139
|
-
assert_kind_of Template, subject["row"]["not_poo"]
|
138
|
+
assert_kind_of Osheet::Template, subject["row"]["not_poo"]
|
140
139
|
assert subject["column"]
|
141
140
|
assert_equal 2, subject["column"].keys.size
|
142
141
|
assert subject["column"]["awesome"]
|
143
|
-
assert_kind_of Template, subject["column"]["awesome"]
|
142
|
+
assert_kind_of Osheet::Template, subject["column"]["awesome"]
|
144
143
|
assert subject["column"]["not_awesome"]
|
145
|
-
assert_kind_of Template, subject["column"]["not_awesome"]
|
144
|
+
assert_kind_of Osheet::Template, subject["column"]["not_awesome"]
|
146
145
|
end
|
147
146
|
|
148
147
|
should "lookup a template by element, name" do
|
149
|
-
t = Template.new(:row, :poo) {}
|
148
|
+
t = Osheet::Template.new(:row, :poo) {}
|
150
149
|
subject << t
|
151
150
|
assert_equal t, subject.get(:row, :poo)
|
152
151
|
assert_equal t, subject.get('row', 'poo')
|
@@ -157,11 +156,9 @@ module Osheet
|
|
157
156
|
|
158
157
|
end
|
159
158
|
|
160
|
-
|
161
|
-
|
162
159
|
class StyleSetTests < Assert::Context
|
163
160
|
desc "a StyleSet"
|
164
|
-
before { @set = WorkbookElement::StyleSet.new }
|
161
|
+
before { @set = Osheet::WorkbookElement::StyleSet.new }
|
165
162
|
subject { @set }
|
166
163
|
|
167
164
|
should "be an Array" do
|
@@ -175,18 +172,18 @@ module Osheet
|
|
175
172
|
subject.send(:verify, {})
|
176
173
|
end
|
177
174
|
assert_nothing_raised do
|
178
|
-
subject.send(:verify, Style.new('.awesome') {})
|
175
|
+
subject.send(:verify, Osheet::Style.new('.awesome') {})
|
179
176
|
end
|
180
177
|
end
|
181
178
|
|
182
179
|
should "be able to lookup styles by class" do
|
183
|
-
subject << (a
|
184
|
-
subject << (at
|
185
|
-
subject << (b
|
186
|
-
subject << (bt
|
187
|
-
subject << (a_b = Style.new('.awesome', '.boring') {})
|
188
|
-
subject << (t
|
189
|
-
subject << (s
|
180
|
+
subject << (a = Osheet::Style.new('.awesome') {})
|
181
|
+
subject << (at = Osheet::Style.new('.awesome.thing') {})
|
182
|
+
subject << (b = Osheet::Style.new('.boring') {})
|
183
|
+
subject << (bt = Osheet::Style.new('.boring.thing') {})
|
184
|
+
subject << (a_b = Osheet::Style.new('.awesome', '.boring') {})
|
185
|
+
subject << (t = Osheet::Style.new('.thing') {})
|
186
|
+
subject << (s = Osheet::Style.new('.stupid') {})
|
190
187
|
|
191
188
|
{ 'awesome' => [a, a_b],
|
192
189
|
'boring' => [b, a_b],
|
@@ -205,11 +202,9 @@ module Osheet
|
|
205
202
|
|
206
203
|
end
|
207
204
|
|
208
|
-
|
209
|
-
|
210
205
|
class WorksheetSetTests < Assert::Context
|
211
206
|
desc "a WorksheetSet"
|
212
|
-
before { @set = WorkbookElement::WorksheetSet.new }
|
207
|
+
before { @set = Osheet::WorkbookElement::WorksheetSet.new }
|
213
208
|
subject { @set }
|
214
209
|
|
215
210
|
should "be an Array" do
|
@@ -221,11 +216,10 @@ module Osheet
|
|
221
216
|
subject.send(:verify, {})
|
222
217
|
end
|
223
218
|
assert_nothing_raised do
|
224
|
-
subject.send(:verify, Worksheet.new {})
|
219
|
+
subject.send(:verify, Osheet::Worksheet.new {})
|
225
220
|
end
|
226
221
|
end
|
227
222
|
|
228
223
|
end
|
229
224
|
|
230
|
-
|
231
225
|
end
|