under-os 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +25 -2
- data/README.md +1 -1
- data/Rakefile +2 -4
- data/lib/under-os.rb +3 -8
- data/under-os.gemspec +6 -2
- metadata +47 -191
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +0 -115
- data/lib/under_os.rb +0 -41
- data/lib/under_os/app.rb +0 -33
- data/lib/under_os/color.rb +0 -184
- data/lib/under_os/config.rb +0 -33
- data/lib/under_os/core/array.rb +0 -5
- data/lib/under_os/core/hash.rb +0 -10
- data/lib/under_os/core/json.rb +0 -19
- data/lib/under_os/core/kernel.rb +0 -16
- data/lib/under_os/core/numeric.rb +0 -23
- data/lib/under_os/core/object.rb +0 -9
- data/lib/under_os/core/string.rb +0 -80
- data/lib/under_os/delegate.rb +0 -10
- data/lib/under_os/events.rb +0 -85
- data/lib/under_os/file.rb +0 -110
- data/lib/under_os/history.rb +0 -53
- data/lib/under_os/http.rb +0 -31
- data/lib/under_os/http/cookies.rb +0 -30
- data/lib/under_os/http/receiver.rb +0 -44
- data/lib/under_os/http/request.rb +0 -106
- data/lib/under_os/http/response.rb +0 -28
- data/lib/under_os/http/session.rb +0 -49
- data/lib/under_os/page.rb +0 -169
- data/lib/under_os/page/builder.rb +0 -96
- data/lib/under_os/page/layout.rb +0 -43
- data/lib/under_os/page/matcher.rb +0 -128
- data/lib/under_os/page/stylesheet.rb +0 -67
- data/lib/under_os/parser.rb +0 -24
- data/lib/under_os/parser/css.rb +0 -37
- data/lib/under_os/parser/html.rb +0 -97
- data/lib/under_os/point.rb +0 -47
- data/lib/under_os/screen.rb +0 -9
- data/lib/under_os/timer.rb +0 -65
- data/lib/under_os/ui.rb +0 -3
- data/lib/under_os/ui/alert.rb +0 -52
- data/lib/under_os/ui/button.rb +0 -42
- data/lib/under_os/ui/collection.rb +0 -65
- data/lib/under_os/ui/collection/cell.rb +0 -21
- data/lib/under_os/ui/collection/delegate.rb +0 -70
- data/lib/under_os/ui/collection/item.rb +0 -32
- data/lib/under_os/ui/collection/layout.rb +0 -43
- data/lib/under_os/ui/collection/styles.rb +0 -15
- data/lib/under_os/ui/div.rb +0 -3
- data/lib/under_os/ui/form.rb +0 -60
- data/lib/under_os/ui/icon.rb +0 -61
- data/lib/under_os/ui/icon/awesome.rb +0 -376
- data/lib/under_os/ui/icon/engine.rb +0 -10
- data/lib/under_os/ui/image.rb +0 -31
- data/lib/under_os/ui/input.rb +0 -140
- data/lib/under_os/ui/label.rb +0 -21
- data/lib/under_os/ui/locker.rb +0 -42
- data/lib/under_os/ui/navbar.rb +0 -123
- data/lib/under_os/ui/progress.rb +0 -17
- data/lib/under_os/ui/scroll.rb +0 -41
- data/lib/under_os/ui/select.rb +0 -95
- data/lib/under_os/ui/sidebar.rb +0 -45
- data/lib/under_os/ui/slider.rb +0 -37
- data/lib/under_os/ui/spinner.rb +0 -23
- data/lib/under_os/ui/style.rb +0 -21
- data/lib/under_os/ui/style/fonts.rb +0 -54
- data/lib/under_os/ui/style/margins.rb +0 -164
- data/lib/under_os/ui/style/outlining.rb +0 -170
- data/lib/under_os/ui/style/positioning.rb +0 -169
- data/lib/under_os/ui/switch.rb +0 -26
- data/lib/under_os/ui/textarea.rb +0 -19
- data/lib/under_os/ui/utils/animation.rb +0 -99
- data/lib/under_os/ui/utils/commons.rb +0 -70
- data/lib/under_os/ui/utils/dimensions.rb +0 -37
- data/lib/under_os/ui/utils/events.rb +0 -170
- data/lib/under_os/ui/utils/manipulation.rb +0 -44
- data/lib/under_os/ui/utils/position.rb +0 -21
- data/lib/under_os/ui/utils/size.rb +0 -21
- data/lib/under_os/ui/utils/styles.rb +0 -89
- data/lib/under_os/ui/utils/traversing.rb +0 -44
- data/lib/under_os/ui/utils/wrap.rb +0 -77
- data/lib/under_os/ui/view.rb +0 -31
- data/resources/test.png +0 -0
- data/spec/assets/app.css +0 -13
- data/spec/assets/test.css +0 -7
- data/spec/assets/test.html +0 -3
- data/spec/assets/test_page.rb +0 -2
- data/spec/lib/core/hash_spec.rb +0 -19
- data/spec/lib/core/json_spec.rb +0 -32
- data/spec/lib/core/numeric_spec.rb +0 -37
- data/spec/lib/core/string_spec.rb +0 -121
- data/spec/lib/under_os/color_spec.rb +0 -133
- data/spec/lib/under_os/events_spec.rb +0 -71
- data/spec/lib/under_os/file_spec.rb +0 -98
- data/spec/lib/under_os/http/cookies_spec.rb +0 -13
- data/spec/lib/under_os/http/request_spec.rb +0 -44
- data/spec/lib/under_os/http_spec.rb +0 -20
- data/spec/lib/under_os/page/builder_spec.rb +0 -128
- data/spec/lib/under_os/page/layout_spec.rb +0 -18
- data/spec/lib/under_os/page/matcher_spec.rb +0 -260
- data/spec/lib/under_os/page/stylesheet_spec.rb +0 -83
- data/spec/lib/under_os/page_spec.rb +0 -5
- data/spec/lib/under_os/parser/css_spec.rb +0 -77
- data/spec/lib/under_os/parser/html_spec.rb +0 -152
- data/spec/lib/under_os/parser_spec.rb +0 -16
- data/spec/lib/under_os/point_spec.rb +0 -54
- data/spec/lib/under_os/screen_spec.rb +0 -11
- data/spec/lib/under_os/timer_spec.rb +0 -93
- data/spec/lib/under_os/ui/button_spec.rb +0 -50
- data/spec/lib/under_os/ui/collection_spec.rb +0 -19
- data/spec/lib/under_os/ui/div_spec.rb +0 -24
- data/spec/lib/under_os/ui/form_spec.rb +0 -156
- data/spec/lib/under_os/ui/icon_spec.rb +0 -57
- data/spec/lib/under_os/ui/image_spec.rb +0 -39
- data/spec/lib/under_os/ui/input_spec.rb +0 -109
- data/spec/lib/under_os/ui/label_spec.rb +0 -22
- data/spec/lib/under_os/ui/locker_spec.rb +0 -31
- data/spec/lib/under_os/ui/progress_spec.rb +0 -31
- data/spec/lib/under_os/ui/scroll_spec.rb +0 -40
- data/spec/lib/under_os/ui/select_spec.rb +0 -135
- data/spec/lib/under_os/ui/sidebar_spec.rb +0 -35
- data/spec/lib/under_os/ui/slider_spec.rb +0 -69
- data/spec/lib/under_os/ui/spinner_spec.rb +0 -57
- data/spec/lib/under_os/ui/style/fonts_spec.rb +0 -73
- data/spec/lib/under_os/ui/style/margins_spec.rb +0 -106
- data/spec/lib/under_os/ui/style/outlining_spec.rb +0 -101
- data/spec/lib/under_os/ui/style/positioning_spec.rb +0 -69
- data/spec/lib/under_os/ui/style_spec.rb +0 -19
- data/spec/lib/under_os/ui/switch_spec.rb +0 -60
- data/spec/lib/under_os/ui/textarea_spec.rb +0 -34
- data/spec/lib/under_os/ui/utils/commons_spec.rb +0 -81
- data/spec/lib/under_os/ui/utils/events_spec.rb +0 -87
- data/spec/lib/under_os/ui/utils/manipulation_spec.rb +0 -130
- data/spec/lib/under_os/ui/utils/styles_spec.rb +0 -140
- data/spec/lib/under_os/ui/utils/traversing_spec.rb +0 -124
- data/spec/lib/under_os/ui/utils/wrap_spec.rb +0 -69
- data/spec/lib/under_os/ui/view_spec.rb +0 -39
@@ -1,87 +0,0 @@
|
|
1
|
-
class MyView < UnderOs::UI::View
|
2
|
-
attr_reader :args
|
3
|
-
|
4
|
-
def handler_with_event(event)
|
5
|
-
@args = [event]
|
6
|
-
end
|
7
|
-
|
8
|
-
def handler_without_event
|
9
|
-
@args = []
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe UnderOs::UI::Events do
|
14
|
-
before do
|
15
|
-
@view = UnderOs::UI::View.new
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#on" do
|
19
|
-
before do
|
20
|
-
@tapped = false
|
21
|
-
@result = @view.on(:tap) { @tapped = true }
|
22
|
-
|
23
|
-
@view.emit(:tap)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "binds the event listener" do
|
27
|
-
@tapped.should == true
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns the view object itself back" do
|
31
|
-
@result.should.be.same_as @view
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#off" do
|
36
|
-
before do
|
37
|
-
@tapped = false
|
38
|
-
@view.on(:tap) { @tapped = true }
|
39
|
-
|
40
|
-
@result = @view.off(:tap)
|
41
|
-
|
42
|
-
@view.emit(:tap)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "un-binds the event listener" do
|
46
|
-
@tapped.should == false
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns the view object itself back" do
|
50
|
-
@result.should.be.same_as @view
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#emit" do
|
55
|
-
before do
|
56
|
-
@view.on(:tap) { |e| @event = e }
|
57
|
-
@view.emit(:tap, custom: 'param')
|
58
|
-
end
|
59
|
-
|
60
|
-
it "emits an UI::Event" do
|
61
|
-
@event.class.should == UnderOs::UI::Events::Event
|
62
|
-
end
|
63
|
-
|
64
|
-
it "sets the event target to the view" do
|
65
|
-
@event.target.should.be.same_as @view
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "named event handlers" do
|
70
|
-
before do
|
71
|
-
@view = MyView.new
|
72
|
-
end
|
73
|
-
|
74
|
-
it "allows to bind a method by name with an event listener" do
|
75
|
-
@view.on :tap, :handler_with_event
|
76
|
-
@view.emit(:tap)
|
77
|
-
@view.args.size.should == 1
|
78
|
-
@view.args[0].class.should == UnderOs::UI::Events::Event
|
79
|
-
end
|
80
|
-
|
81
|
-
it "allows to bind a method by name without an event argument" do
|
82
|
-
@view.on :tap, :handler_without_event
|
83
|
-
@view.emit(:tap)
|
84
|
-
@view.args.size.should == 0
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
describe UnderOs::UI::Manipulation do
|
2
|
-
before do
|
3
|
-
@v1 = UnderOs::UI::View.new
|
4
|
-
@v2 = UnderOs::UI::View.new
|
5
|
-
@v3 = UnderOs::UI::View.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '#insert' do
|
9
|
-
it "should let insert views inside of each other" do
|
10
|
-
@v1.insert(@v2)
|
11
|
-
@v1.insert(@v3)
|
12
|
-
|
13
|
-
@v1.children.should == [@v2, @v3]
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should let insert views on top of the subviews" do
|
17
|
-
@v1.insert(@v2)
|
18
|
-
@v1.insert(@v3, :top)
|
19
|
-
|
20
|
-
@v1.children.should == [@v3, @v2]
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return the view itself after each operation" do
|
24
|
-
@v1.insert(@v2).should == @v1
|
25
|
-
@v1.insert(@v3).should == @v1
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should accept lists of items" do
|
29
|
-
@v1.insert([@v2, @v3])
|
30
|
-
@v1.children.should == [@v2, @v3]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#append' do
|
35
|
-
it "should append other views into the current one" do
|
36
|
-
@v1.append(@v2)
|
37
|
-
@v1.append(@v3)
|
38
|
-
|
39
|
-
@v1.children.should == [@v2, @v3]
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should allow to append several views as multiple arguments" do
|
43
|
-
@v1.append(@v2, @v3)
|
44
|
-
|
45
|
-
@v1.children.should == [@v2, @v3]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return the view itself after each operation" do
|
49
|
-
@v1.append(@v2).should == @v1
|
50
|
-
@v1.append(@v3).should == @v1
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#prepend' do
|
55
|
-
it "should put all items on top" do
|
56
|
-
@v1.prepend(@v2)
|
57
|
-
@v1.prepend(@v3)
|
58
|
-
|
59
|
-
@v1.children.should == [@v3, @v2]
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should accept several views as multiple arguments" do
|
63
|
-
@v1.prepend(@v2, @v3)
|
64
|
-
|
65
|
-
@v1.children.should == [@v3, @v2]
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should return the view itself after each operation" do
|
69
|
-
@v1.prepend(@v2).should == @v1
|
70
|
-
@v1.prepend(@v3).should == @v1
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#insertTo' do
|
75
|
-
it "should allow to insert view into others" do
|
76
|
-
@v2.insertTo(@v1)
|
77
|
-
@v3.insertTo(@v1)
|
78
|
-
|
79
|
-
@v1.children.should == [@v2, @v3]
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should allo to insert intems on top of the stack" do
|
83
|
-
@v1.insert(@v2)
|
84
|
-
@v3.insertTo(@v1, :top)
|
85
|
-
|
86
|
-
@v1.children.should == [@v3, @v2]
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should return the view itself after each operation" do
|
90
|
-
@v2.insertTo(@v1).should == @v2
|
91
|
-
@v3.insertTo(@v1).should == @v3
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#remove' do
|
96
|
-
it "should allow to remove items from superviews" do
|
97
|
-
@v1.append(@v2, @v3)
|
98
|
-
|
99
|
-
@v2.remove
|
100
|
-
|
101
|
-
@v1.children.should == [@v3]
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should not crash if there is no superviews" do
|
105
|
-
@v1.remove
|
106
|
-
@v2.remove
|
107
|
-
@v3.remove
|
108
|
-
true.should == true
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should return the view iteslf back" do
|
112
|
-
@v1.remove.should == @v1
|
113
|
-
@v2.remove.should == @v2
|
114
|
-
@v3.remove.should == @v3
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '#clear' do
|
119
|
-
before { @v1.append(@v2, @v3) }
|
120
|
-
|
121
|
-
it "should remove all the child elements" do
|
122
|
-
@v1.clear
|
123
|
-
@v1.children.should == []
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should return itself back as a reference" do
|
127
|
-
@v1.clear.should.be.same_as @v1
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
describe UnderOs::UI::Styles do
|
2
|
-
before do
|
3
|
-
@view = UnderOs::UI::View.new
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '#style' do
|
7
|
-
it "should return a style handler for the view" do
|
8
|
-
style = @view.style
|
9
|
-
style.class.should == UnderOs::UI::Style
|
10
|
-
style.view.should.be.same_as @view._
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should cache the styles handler instance" do
|
14
|
-
@view.style.should.be.same_as @view.style
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should allow to set the styles as a hash" do
|
18
|
-
@view.style = {top: 10, left: 20}
|
19
|
-
@view.style.top.should == 10
|
20
|
-
@view.style.left.should == 20
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#classNames' do
|
25
|
-
it "should return an empty list by default" do
|
26
|
-
@view.classNames.should == []
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should allow to assign the lists" do
|
30
|
-
@view.classNames = ['one', 'two']
|
31
|
-
@view.classNames.should == ['one', 'two']
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should remove dups on fly" do
|
35
|
-
@view.classNames = ['one', 'two', 'two', 'one']
|
36
|
-
@view.classNames.should == ['one', 'two']
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#className' do
|
41
|
-
it "should return an empty string by default" do
|
42
|
-
@view.className.should == ''
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should allow to assign new class names" do
|
46
|
-
@view.className = 'one two'
|
47
|
-
@view.className.should == 'one two'
|
48
|
-
@view.classNames.should == ['one', 'two']
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#hasClass' do
|
53
|
-
it "should return 'true' if the view has the class" do
|
54
|
-
@view.className = 'boo hoo'
|
55
|
-
@view.hasClass('boo').should == true
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should return false if the view has no class" do
|
59
|
-
@view.className = 'boo hoo'
|
60
|
-
@view.hasClass('foo').should == false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#addClass' do
|
65
|
-
it "should add the class name if it's missing" do
|
66
|
-
@view.addClass 'boo'
|
67
|
-
@view.classNames.should == ['boo']
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should not duplicat the class if it's already exists" do
|
71
|
-
@view.classNames = ['boo']
|
72
|
-
@view.addClass 'boo'
|
73
|
-
@view.classNames.should == ['boo']
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should return the view itself back" do
|
77
|
-
@view.addClass('boo').should === @view
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#removeClass' do
|
82
|
-
it "should remove the class name if it was set" do
|
83
|
-
@view.classNames = ['boo']
|
84
|
-
@view.removeClass('boo')
|
85
|
-
@view.classNames.should == []
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return the view itself back" do
|
89
|
-
@view.removeClass('boo').should === @view
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe '#toggleClass' do
|
94
|
-
it "should add the class if it's missing" do
|
95
|
-
@view.toggleClass('test')
|
96
|
-
@view.classNames.should == ['test']
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should remove the class if was set before" do
|
100
|
-
@view.classNames = ['test']
|
101
|
-
@view.toggleClass('test')
|
102
|
-
@view.classNames.should == []
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should return the view itself back" do
|
106
|
-
@view.toggleClass('test').should === @view
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#radioClass' do
|
111
|
-
before do
|
112
|
-
@v1 = UnderOs::UI::View.new.insertTo(@view)
|
113
|
-
@v2 = UnderOs::UI::View.new.insertTo(@view)
|
114
|
-
@v3 = UnderOs::UI::View.new.insertTo(@view)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should set the class only on one element" do
|
118
|
-
@v2.radioClass('boo')
|
119
|
-
|
120
|
-
@v1.hasClass('boo').should == false
|
121
|
-
@v2.hasClass('boo').should == true
|
122
|
-
@v1.hasClass('boo').should == false
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should automatically remove the class from any of the siblings" do
|
126
|
-
@v1.className = 'boo'
|
127
|
-
@v3.className = 'boo'
|
128
|
-
|
129
|
-
@v2.radioClass('boo')
|
130
|
-
|
131
|
-
@v1.hasClass('boo').should == false
|
132
|
-
@v2.hasClass('boo').should == true
|
133
|
-
@v1.hasClass('boo').should == false
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should return the view itself back" do
|
137
|
-
@v2.radioClass('boo').should === @v2
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
describe UnderOs::UI::Traversing do
|
2
|
-
|
3
|
-
before do
|
4
|
-
@v1 = UnderOs::UI::View.new
|
5
|
-
@v2 = UnderOs::UI::View.new
|
6
|
-
@v3 = UnderOs::UI::View.new
|
7
|
-
@v4 = UnderOs::UI::View.new
|
8
|
-
@v5 = UnderOs::UI::View.new
|
9
|
-
@v6 = UnderOs::UI::View.new
|
10
|
-
|
11
|
-
@v1.append(
|
12
|
-
@v2.append(
|
13
|
-
@v3,
|
14
|
-
@v4.append(
|
15
|
-
@v5.append(
|
16
|
-
@v6
|
17
|
-
))))
|
18
|
-
|
19
|
-
@v2.className = 'v1 v2'
|
20
|
-
@v3.className = 'v1 v3'
|
21
|
-
@v4.className = 'v3 v4'
|
22
|
-
@v5.className = 'v5'
|
23
|
-
@v6.className = 'v6'
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#find' do
|
27
|
-
it "should return a list of matching items from all levels" do
|
28
|
-
@v1.find('.v1').should == [@v2, @v3]
|
29
|
-
@v1.find('.v3').should == [@v3, @v4]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return an empty list when nothing's found" do
|
33
|
-
@v1.find(".non-existing").should == []
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#first' do
|
38
|
-
it "should return the first correctly matching view" do
|
39
|
-
@v1.first('.v1').should == @v2
|
40
|
-
@v1.first('.v3').should == @v3
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return nil when nothing matching found" do
|
44
|
-
@v1.first('.non-existing').should == nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#matches' do
|
49
|
-
it "should return 'true' when it's given a matching css-rule" do
|
50
|
-
@v2.matches('.v2').should == true
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should return 'false' when it's given a non-matching css-rule" do
|
54
|
-
@v2.matches('.something-else').should == false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#parent' do
|
59
|
-
it "should be nil by default" do
|
60
|
-
@v1.parent.should == nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should return the correct view if the parent is set" do
|
64
|
-
@v2.parent.should == @v1
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should search for a matching parent if a css-rule was specified" do
|
68
|
-
@v6.parent('.v4').should == @v4
|
69
|
-
@v6.parent('.v2').should == @v2
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should return nil if a css-rule was specified and nothing matches" do
|
73
|
-
@v6.parent('.non-existing').should == nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#children' do
|
78
|
-
it "should return an empty array by default" do
|
79
|
-
@v6.children.should == []
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should return the list of children when there are some" do
|
83
|
-
@v1.children.should == [@v2]
|
84
|
-
@v2.children.should == [@v3, @v4]
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should filter the list by a css-rule if one was given" do
|
88
|
-
@v2.children('.v4').should == [@v4]
|
89
|
-
@v2.children('.non-existing').should == []
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should return an empty list on leaf elements like buttons" do
|
93
|
-
UnderOs::UI::Image.new.children.should == []
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#siblings' do
|
98
|
-
it "should return the list of sibling nodes" do
|
99
|
-
@v3.siblings.should == [@v4]
|
100
|
-
@v4.siblings.should == [@v3]
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should accept a css rule as a filter" do
|
104
|
-
@v3.siblings('.v4').should == [@v4]
|
105
|
-
@v3.siblings('.non-existing').should == []
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should fall back to an empty list when there is no parent" do
|
109
|
-
UnderOs::UI::View.new.siblings.should == []
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe '#empty?' do
|
114
|
-
it "should return true when there is no child elements" do
|
115
|
-
view = UnderOs::UI::View.new
|
116
|
-
view.empty?.should == true
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should return false when there are child elements" do
|
120
|
-
@v1.empty?.should == false
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|