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,20 +0,0 @@
|
|
1
|
-
describe UnderOs::HTTP do
|
2
|
-
extend Facon::SpecHelpers
|
3
|
-
|
4
|
-
before do
|
5
|
-
@url = 'http://test.com'
|
6
|
-
@req = mock 'request', send: :request
|
7
|
-
end
|
8
|
-
|
9
|
-
%w[get post put patch head delete].each do |method|
|
10
|
-
describe ".#{method}" do
|
11
|
-
it "sends a #{method.upcase} request" do
|
12
|
-
UnderOs::HTTP::Request.should.receive(:new)
|
13
|
-
.with(@url, foo: 'bar', method: method.to_sym)
|
14
|
-
.and_return(@req)
|
15
|
-
|
16
|
-
UnderOs::HTTP.__send__(method, @url, foo: 'bar').should == :request
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
describe UnderOs::Page::Builder do
|
2
|
-
def build(html)
|
3
|
-
UnderOs::Page::Builder.views_from(html)
|
4
|
-
end
|
5
|
-
|
6
|
-
describe 'generic build' do
|
7
|
-
before do
|
8
|
-
@result = build("<view id='my-view'></view>")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return an array" do
|
12
|
-
@result.class.should == Array
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should build just one item" do
|
16
|
-
@result.size.should == 1
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should build an UnderOs::UI::View instance" do
|
20
|
-
@result[0].class.should == UnderOs::UI::View
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should assign the element properties" do
|
24
|
-
@result[0].id.should == 'my-view'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'types building' do
|
29
|
-
it "should build buttons" do
|
30
|
-
button = build(%Q{<button class="my-button">Some text</button>})[0]
|
31
|
-
button.class.should == UnderOs::UI::Button
|
32
|
-
button.classNames.should == ['my-button']
|
33
|
-
button.text.should == 'Some text'
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should build labels" do
|
37
|
-
label = build(%Q{<label>The Text</label>})[0]
|
38
|
-
label.class.should == UnderOs::UI::Label
|
39
|
-
label.text.should == 'The Text'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should build images" do
|
43
|
-
image = build(%Q{<img src="test.png">})[0]
|
44
|
-
image.class.should == UnderOs::UI::Image
|
45
|
-
image.src.class.should == UIImage
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should build icons" do
|
49
|
-
icon = build(%Q{<icon type="ok" />})[0]
|
50
|
-
icon.class.should == UnderOs::UI::Icon
|
51
|
-
icon.type.should == 'ok'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'nested build' do
|
56
|
-
before do
|
57
|
-
@result = build(%Q{
|
58
|
-
<page id="level1">
|
59
|
-
<view id="level2">
|
60
|
-
<label>A</label>
|
61
|
-
<button>B</button>
|
62
|
-
</view>
|
63
|
-
</page>
|
64
|
-
})[0]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should still assign the top level element attributes" do
|
68
|
-
@result.id.should == 'level1'
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should build the second level elements" do
|
72
|
-
level2 = @result.children
|
73
|
-
level2.size.should == 1
|
74
|
-
level2[0].id.should == 'level2'
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should build the third level of the elements" do
|
78
|
-
level3 = @result.children[0].children
|
79
|
-
level3.size.should == 2
|
80
|
-
level3.map(&:class).should == [UnderOs::UI::Label, UnderOs::UI::Button]
|
81
|
-
level3.map(&:text).should == ['A', 'B']
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'selectboxes build' do
|
86
|
-
before do
|
87
|
-
@result = build(%Q{
|
88
|
-
<select>
|
89
|
-
<option value="1">One</option>
|
90
|
-
<option value="2">Two</option>
|
91
|
-
<option>Three</option>
|
92
|
-
</select>
|
93
|
-
})[0]
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should allow to build a select box" do
|
97
|
-
@result.class.should == UnderOs::UI::Select
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should recognize options" do
|
101
|
-
@result.options.should == {
|
102
|
-
'1' => 'One',
|
103
|
-
'2' => 'Two',
|
104
|
-
'Three' => 'Three'
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should allow to build multi-select boxes" do
|
109
|
-
select = build(%Q{
|
110
|
-
<select>
|
111
|
-
<optgroup>
|
112
|
-
<option value="1">One</option>
|
113
|
-
</optgroup>
|
114
|
-
<optgroup>
|
115
|
-
<option value="2">Two</option>
|
116
|
-
</optgroup>
|
117
|
-
<optgroup>
|
118
|
-
<option value="3">Three</option>
|
119
|
-
</optgroup>
|
120
|
-
</select>
|
121
|
-
})[0]
|
122
|
-
|
123
|
-
select.optgroups.should == [
|
124
|
-
{'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
|
125
|
-
]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
describe UnderOs::Page::Layout do
|
2
|
-
before do
|
3
|
-
@page = TestPage.new
|
4
|
-
@layout = UnderOs::Page::Layout.new(@page)
|
5
|
-
end
|
6
|
-
|
7
|
-
it "should pickup the elements from the layout.html file" do
|
8
|
-
@page.view.should.not == nil
|
9
|
-
children = @page.view.children
|
10
|
-
children.size.should == 1
|
11
|
-
children[0].class.should == UnderOs::UI::Button
|
12
|
-
children[0].text.should == 'Say Hello'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should pickup the page title from the test layout" do
|
16
|
-
@page.title.should == 'Hello World'
|
17
|
-
end
|
18
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
describe UnderOs::Page::StylesMatcher do
|
2
|
-
before do
|
3
|
-
@view = UnderOs::UI::View.new
|
4
|
-
@view1 = UnderOs::UI::View.new
|
5
|
-
@view2 = UnderOs::UI::View.new
|
6
|
-
@matcher = UnderOs::Page::StylesMatcher.new('smth')
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
it "should cache instances" do
|
11
|
-
@i1 = UnderOs::Page::StylesMatcher.new('.one')
|
12
|
-
@i2 = UnderOs::Page::StylesMatcher.new('.one')
|
13
|
-
@i3 = UnderOs::Page::StylesMatcher.new('.two')
|
14
|
-
|
15
|
-
@i1.should.be.same_as @i2
|
16
|
-
@i1.should.not == @i3
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#match' do
|
21
|
-
it "should return 'true' for views with score > 0" do
|
22
|
-
def @matcher.score_for(view); 1 end
|
23
|
-
@matcher.match(@view).should == true
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should return 'false' for views with score == 0" do
|
27
|
-
def @matcher.score_for(view); 0 end
|
28
|
-
@matcher.match(@view).should == false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#score_for' do
|
33
|
-
def score_for(view, css_rule)
|
34
|
-
UnderOs::Page::StylesMatcher.new(css_rule).score_for(view)
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'tags matching' do
|
38
|
-
it "should add score for tag match" do
|
39
|
-
score_for(@view, 'view').should == 1
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should not add score for not matching tags" do
|
43
|
-
score_for(@view, 'button').should == 0
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should not add score if the id is wrong" do
|
47
|
-
score_for(@view, 'view#some-id').should == 0
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should not add score if the css-rule is wrong" do
|
51
|
-
score_for(@view, 'view.some-class').should == 0
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should handle the * as the tag name" do
|
55
|
-
score_for(@view, '*').should == 1
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'IDs matching' do
|
60
|
-
it "should add score for IDs matches" do
|
61
|
-
@view.id = 'my-id'
|
62
|
-
score_for(@view, '#my-id').should == 1
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should not add score for mismatching IDs" do
|
66
|
-
@view.id = 'my-id'
|
67
|
-
score_for(@view, '#another-id').should == 0
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should not crash if ID is missing" do
|
71
|
-
score_for(@view, 'button').should == 0
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should not add points if the tag is different" do
|
75
|
-
@view.id = 'my-id'
|
76
|
-
score_for(@view, 'button#my-id').should == 0
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'className matching' do
|
81
|
-
it "should add score for matching class names" do
|
82
|
-
@view.className = 'my-class'
|
83
|
-
score_for(@view, '.my-class').should == 1
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should not add score for mismatching class names" do
|
87
|
-
@view.className = 'my-class'
|
88
|
-
score_for(@view, '.another-class').should == 0
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should add point for every matching class name" do
|
92
|
-
@view.className = 'class1 class2'
|
93
|
-
score_for(@view, '.class1.class2').should == 2
|
94
|
-
score_for(@view, '.class2.class1').should == 2
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should not add points one of multiple classes don't match" do
|
98
|
-
@view.className = 'class1 class2'
|
99
|
-
score_for(@view, '.class1.class3').should == 0
|
100
|
-
score_for(@view, '.class3.class2').should == 0
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should not add points if the tag is different" do
|
104
|
-
@view.className = 'my-class'
|
105
|
-
score_for(@view, 'button.my-class').should == 0
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should not add points if the ID is different" do
|
109
|
-
@view.className = 'my-class'
|
110
|
-
score_for(@view, '#another-id.my-class').should == 0
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "attribute matchers" do
|
115
|
-
before do
|
116
|
-
@view.id = "my-view"
|
117
|
-
end
|
118
|
-
|
119
|
-
def score_for(view, css_rule)
|
120
|
-
UnderOs::Page::StylesMatcher.new(css_rule).score_for(view)
|
121
|
-
end
|
122
|
-
|
123
|
-
describe "with the '=' operator" do
|
124
|
-
it "scores when the value matches exactly" do
|
125
|
-
score_for(@view, '[id="my-view"]').should == 1
|
126
|
-
end
|
127
|
-
|
128
|
-
it "doesn't count when the value does not match" do
|
129
|
-
score_for(@view, "[id='my']").should == 0
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "with the '*=' operator" do
|
134
|
-
it "scores when the attribute includes the value" do
|
135
|
-
score_for(@view, '[id*=vie]').should == 1
|
136
|
-
end
|
137
|
-
|
138
|
-
it "doesn't count when the value doesn't match attribute" do
|
139
|
-
score_for(@view, '[id*=mismatch]').should == 0
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "with the ^= operator" do
|
144
|
-
it "scores when the attribute starts with the value" do
|
145
|
-
score_for(@view, '[id^=my]').should == 1
|
146
|
-
end
|
147
|
-
|
148
|
-
it "doesn't count when the attribute doesn't start with the value" do
|
149
|
-
score_for(@view, '[id^=view]').should == 0
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "with the $= operator" do
|
154
|
-
it "scores when the attribute ends with the value" do
|
155
|
-
score_for(@view, '[id$=view]').should == 1
|
156
|
-
end
|
157
|
-
|
158
|
-
it "doesn't count when the attribute doesn't ends with the value" do
|
159
|
-
score_for(@view, '[id$=my]').should == 0
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "with the ~= operator" do
|
164
|
-
before { @view.id = "one two three" }
|
165
|
-
|
166
|
-
it "scores when the value is a token from the attribute" do
|
167
|
-
score_for(@view, '[id~=one]').should == 1
|
168
|
-
score_for(@view, '[id~=two]').should == 1
|
169
|
-
score_for(@view, '[id~=three]').should == 1
|
170
|
-
end
|
171
|
-
|
172
|
-
it "doesn't trigger on completely different strings" do
|
173
|
-
score_for(@view, '[id~=four]').should == 0
|
174
|
-
end
|
175
|
-
|
176
|
-
it "doesn't trigger on partial substrings" do
|
177
|
-
score_for(@view, '[id~=tw]').should == 0
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "with the |= operator" do
|
182
|
-
it "scores when value is a dashed token of the attribute" do
|
183
|
-
score_for(@view, '[id|=my]').should == 1
|
184
|
-
score_for(@view, '[id|=view]').should == 1
|
185
|
-
end
|
186
|
-
|
187
|
-
it "doesn't trigger on completely different values" do
|
188
|
-
score_for(@view, '[id|=mismatch]').should == 0
|
189
|
-
end
|
190
|
-
|
191
|
-
it "doesn't trigger on partial matches" do
|
192
|
-
score_for(@view, '[id|=vie]').should == 0
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe 'multiple nested matches' do
|
198
|
-
it "should count in all the matches" do
|
199
|
-
@view.id = 'my-id'
|
200
|
-
@view.className = 'class1 class2'
|
201
|
-
score_for(@view, 'view#my-id.class1.class2').should == 4
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe 'in multi-leveled structures' do
|
206
|
-
before do
|
207
|
-
@v1 = UnderOs::UI::View.new(class: 'v1')
|
208
|
-
@v2 = UnderOs::UI::View.new(class: 'v2')
|
209
|
-
@v3 = UnderOs::UI::View.new(class: 'v3')
|
210
|
-
@v4 = UnderOs::UI::View.new(class: 'v4')
|
211
|
-
|
212
|
-
@v1.append(@v2.append(@v3.append(@v4.append(@view))))
|
213
|
-
|
214
|
-
@view.id = 'my-view'
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should still match singular rules" do
|
218
|
-
score_for(@view, '#my-view').should == 1
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should add points for matching parent" do
|
222
|
-
score_for(@view, '.v4 #my-view').should == 2
|
223
|
-
score_for(@view, 'view.v4 #my-view').should == 3
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should add multiple points for multiple matching parents" do
|
227
|
-
score_for(@view, '.v1 .v2 .v3 .v4 #my-view').should == 5
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should match parents at any level" do
|
231
|
-
score_for(@view, '.v3 #my-view').should == 2
|
232
|
-
score_for(@view, '.v2 #my-view').should == 2
|
233
|
-
score_for(@view, '.v1 .v3 #my-view').should == 3
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should return 0 if no matching parent found" do
|
237
|
-
score_for(@view, '.non-existing #my-view').should == 0
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "multiple different matchers" do
|
242
|
-
before do
|
243
|
-
@view.id = 'my-view'
|
244
|
-
@view.className = 'classy'
|
245
|
-
end
|
246
|
-
|
247
|
-
it "gets score out of multiple matchers if one of them is matching" do
|
248
|
-
score_for(@view, "view, input, form").should == 1
|
249
|
-
end
|
250
|
-
|
251
|
-
it "return 0 if none of the matchers are matching" do
|
252
|
-
score_for(@view, "input,select").should == 0
|
253
|
-
end
|
254
|
-
|
255
|
-
it "gets the max score if there are multiple matches" do
|
256
|
-
score_for(@view, "view,.classy,view#my-view").should == 2
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
describe UnderOs::Page::Stylesheet do
|
2
|
-
before do
|
3
|
-
@stylesheet = UnderOs::Page::Stylesheet.new
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '#initialize' do
|
7
|
-
it "should make an empty stylesheet" do
|
8
|
-
@stylesheet.rules.should == {}
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should allow initialize with some rules" do
|
12
|
-
stylesheet = UnderOs::Page::Stylesheet.new(button: {color: 'orange'})
|
13
|
-
stylesheet.rules.should == {'button' => {color: 'orange'}}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#[]' do
|
18
|
-
it "should allow to set new style rules" do
|
19
|
-
@stylesheet['button'] = {color: :red}
|
20
|
-
@stylesheet['button'].should == {color: :red}
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should allow to extend the rules" do
|
24
|
-
@stylesheet['button'] = {color: 'red'}
|
25
|
-
@stylesheet['button'] = {right: 50 }
|
26
|
-
@stylesheet['button'].should == {color: 'red', right: 50}
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should overwrite existing rules when match" do
|
30
|
-
@stylesheet['button'] = {color: 'red', left: 20}
|
31
|
-
@stylesheet['button'] = {color: 'blue'}
|
32
|
-
@stylesheet['button'].should == {color: 'blue', left: 20}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#<<' do
|
37
|
-
it "should merge another stylesheet into the current one" do
|
38
|
-
other_sytles = UnderOs::Page::Stylesheet.new(button: { color: 'blue' })
|
39
|
-
@stylesheet['button'] = {left: 30}
|
40
|
-
@stylesheet << other_sytles
|
41
|
-
@stylesheet['button'].should == {color: 'blue', left: 30}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#+' do
|
46
|
-
it "should create a new stylesheet combined out of the two" do
|
47
|
-
sheet1 = UnderOs::Page::Stylesheet.new(button: { color: 'blue' })
|
48
|
-
sheet2 = UnderOs::Page::Stylesheet.new(button: { left: 20 })
|
49
|
-
|
50
|
-
sheet3 = sheet1 + sheet2
|
51
|
-
|
52
|
-
sheet1['button'].should == {color: 'blue'}
|
53
|
-
sheet2['button'].should == {left: 20}
|
54
|
-
sheet3['button'].should == {color: 'blue', left: 20}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#load' do
|
59
|
-
it "should load rules from the given test stylesheet file" do
|
60
|
-
@stylesheet.load('test.css')
|
61
|
-
@stylesheet.rules.should == {
|
62
|
-
"page"=>{:backgroundColor=>"yellow"},
|
63
|
-
".test"=>{:backgroundColor=>"green"}
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#styles_for' do
|
69
|
-
before do
|
70
|
-
@view = UnderOs::UI::View.new(class: 'test')
|
71
|
-
@stylesheet.load('app.css')
|
72
|
-
@stylesheet.load('test.css')
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should calculate the styles correctly" do
|
76
|
-
@stylesheet.styles_for(@view).should == {
|
77
|
-
color: 'yellow',
|
78
|
-
backgroundColor: 'green',
|
79
|
-
borderRadius: 10
|
80
|
-
}
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|