under-os 1.3.0 → 1.4.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.
- 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,121 +0,0 @@
|
|
|
1
|
-
describe String do
|
|
2
|
-
describe '#underscore' do
|
|
3
|
-
it "converts camelized strings into underscored" do
|
|
4
|
-
"SomeStuff".underscore.should == 'some_stuff'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it "converts dashed strings into underscored as well" do
|
|
8
|
-
"some-stuff".underscore.should == "some_stuff"
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#camelize" do
|
|
13
|
-
it "converts underscored strings into camelized" do
|
|
14
|
-
"some_stuff".camelize.should == "someStuff"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "converts dashed strings into camelized as well" do
|
|
18
|
-
"some-stuff".camelize.should == "someStuff"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "handles prefixes correctly" do
|
|
22
|
-
"_some_stuff".camelize.should == "SomeStuff"
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe '#dasherize' do
|
|
27
|
-
it "converts camelized strings into dashed" do
|
|
28
|
-
"SomeStuff".dasherize.should == "some-stuff"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "converts underscored strings into dashed as well" do
|
|
32
|
-
"some_stuff".dasherize.should == "some-stuff"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe '#capitalize' do
|
|
37
|
-
it "capitalizes strings" do
|
|
38
|
-
"some stuff".capitalize.should == "Some stuff"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe '#starts_with?' do
|
|
43
|
-
it "returns true if a string starts with the substring" do
|
|
44
|
-
"some stuff".starts_with?("some").should == true
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "returns false if the string doesn't start with the substring" do
|
|
48
|
-
"some stuff".starts_with?("non matching").should == false
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe '#ends_with?' do
|
|
53
|
-
it "returns true if the string ends with the given substring" do
|
|
54
|
-
"some stuff".ends_with?("stuff").should == true
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "returns false if the string doesn't end with the substring" do
|
|
58
|
-
"some stuff".ends_with?("non matching").should == false
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe '#blank?' do
|
|
63
|
-
it "returns true if the string is empty" do
|
|
64
|
-
''.blank?.should == true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "returns true if the string has only white spaces" do
|
|
68
|
-
" \n\t\r ".blank?.should == true
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "returns false if the string has non-space chars in it" do
|
|
72
|
-
" a ".blank?.should == false
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe '#constantize' do
|
|
77
|
-
it "returns an object from it's value" do
|
|
78
|
-
"UnderOs::UI::View".constantize.should == UnderOs::UI::View
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "raises an error if the constant is missing" do
|
|
82
|
-
-> {
|
|
83
|
-
"Something::Totally::Bogus".constantize
|
|
84
|
-
}.should.raise(NameError)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe '#url_encode' do
|
|
89
|
-
it "escapes all the URL sensitive symbols" do
|
|
90
|
-
"!*'\"();:@&=+$,/?%#[]% ".url_encode.should == "!*'%22();:@&=+$,/?%25%23%5B%5D%25%20"
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "doesn't touch normal characters" do
|
|
94
|
-
"Hello World".url_encode.should == "Hello%20World"
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe '#url_decode' do
|
|
99
|
-
it "converts an url encoded string back to normality" do
|
|
100
|
-
"!*'%22();:@&=+$,/?%25%23%5B%5D%25%20".url_decode.should == "!*'\"();:@&=+$,/?%#[]% "
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "doesn't break normal characters" do
|
|
104
|
-
"Hello%20World".url_decode.should == "Hello World"
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
describe '#to_data' do
|
|
109
|
-
before do
|
|
110
|
-
@data = "ohai there".to_data
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it "converts the string into a data object" do
|
|
114
|
-
@data.is_a?(NSData).should == true
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "converts it into data with correct content" do
|
|
118
|
-
@data.to_s.should == "ohai there"
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
describe UnderOs::Color do
|
|
2
|
-
def from(*args)
|
|
3
|
-
UnderOs::Color.new(*args)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
describe '#initialize' do
|
|
7
|
-
it "should initialize from a UIColor" do
|
|
8
|
-
color = from(UIColor.blueColor)
|
|
9
|
-
color.ui.should == UIColor.blueColor
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should always return the same instance" do
|
|
13
|
-
color1 = from(UIColor.blackColor)
|
|
14
|
-
color2 = from(UIColor.blackColor)
|
|
15
|
-
|
|
16
|
-
color1.should === color2
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should work with rgba arrays of integers" do
|
|
20
|
-
from(0, 0, 255, 1.0).should == UIColor.blueColor
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should work with rgba arrays of floats" do
|
|
24
|
-
from(0.0, 0.0, 1.0, 1.0).should == UIColor.blueColor
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should work with rgb arrays of integers" do
|
|
28
|
-
from(0, 0, 255).should == UIColor.blueColor
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should work with rgb arrays of floats" do
|
|
32
|
-
from(0.0, 0.0, 1.0).should == UIColor.blueColor
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should work with string color names" do
|
|
36
|
-
from('blue').should == UIColor.blueColor
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should work with symbol color names" do
|
|
40
|
-
from(:blue).should == UIColor.blueColor
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should work with string hex colors" do
|
|
44
|
-
from('#ff8000').should == UIColor.orangeColor
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should work with short hand colors" do
|
|
48
|
-
from('#ff0').should == UIColor.yellowColor
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should work with rgb() strings" do
|
|
52
|
-
from('rgb(10, 20, 30)').to_rgba.should == [10, 20, 30, 1.0]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should work with rgba() strings" do
|
|
56
|
-
from('rgba(100, 200, 250, 0.5)').to_rgba.should == [100, 200, 250, 0.5]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'should work with flaot color circle params' do
|
|
60
|
-
from(0.23).to_s.should == '#9eff00'
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'should work with integer (in degrees) color circle params' do
|
|
64
|
-
from(23).to_s.should == '#9eff00'
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
describe '#to_rgba' do
|
|
69
|
-
it "should extract the data correctly" do
|
|
70
|
-
from(UIColor.blueColor).to_rgba.should == [0, 0, 255, 1.0]
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe '#to_rgb' do
|
|
75
|
-
it "should extract the data correctly" do
|
|
76
|
-
from(UIColor.yellowColor).to_rgb.should == [255, 255, 0]
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe '#to_hex' do
|
|
81
|
-
it "should extract the data correctly" do
|
|
82
|
-
from(UIColor.orangeColor).to_hex.should == '#ff8000'
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
describe '#to_s' do
|
|
87
|
-
it "should extract the data correctly" do
|
|
88
|
-
from(UIColor.brownColor).to_s.should == '#996633'
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe '#==' do
|
|
93
|
-
it "should work with other colors" do
|
|
94
|
-
from(UIColor.blueColor).should == from(UIColor.blueColor)
|
|
95
|
-
from(UIColor.blueColor).should.not == from(UIColor.orangeColor)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should work with UIColors" do
|
|
99
|
-
from(UIColor.blueColor).should == UIColor.blueColor
|
|
100
|
-
from(UIColor.blueColor).should.not == UIColor.orangeColor
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "should work with RGB arrays" do
|
|
104
|
-
from(UIColor.blueColor).should == [0, 0, 255]
|
|
105
|
-
from(UIColor.blueColor).should.not == [0, 255, 0]
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "should work with RGBA arrays" do
|
|
109
|
-
from(UIColor.blueColor).should == [0, 0, 255, 1.0]
|
|
110
|
-
from(UIColor.blueColor).should.not == [0, 255, 0, 1.0]
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it "should work with string names" do
|
|
114
|
-
from(UIColor.blueColor).should == 'blue'
|
|
115
|
-
from(UIColor.blueColor).should.not == 'orange'
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "should work with symbol names" do
|
|
119
|
-
from(UIColor.blueColor).should == :blue
|
|
120
|
-
from(UIColor.blueColor).should.not == :orange
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "should work with hex values" do
|
|
124
|
-
from(UIColor.blueColor).should == '#0000ff'
|
|
125
|
-
from(UIColor.blueColor).should.not == '#00ff00'
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "should work with short hex values" do
|
|
129
|
-
from(UIColor.blueColor).should == '#00f'
|
|
130
|
-
from(UIColor.blueColor).should.not == '#0f0'
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
describe UnderOs::Events do
|
|
2
|
-
class Dummy
|
|
3
|
-
include UnderOs::Events
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
@dummy = Dummy.new
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "#on" do
|
|
11
|
-
it "should add event listeners" do
|
|
12
|
-
@dummy.on(:smth) { }
|
|
13
|
-
UnderOs::Events::Listeners.all(@dummy, :smth).size.should == 1
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should return the object itself back" do
|
|
17
|
-
@dummy.on(:smth) { }.should.be.same_as @dummy
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe "#off" do
|
|
22
|
-
it "should remove event listeners" do
|
|
23
|
-
@dummy.on(:smth) { }
|
|
24
|
-
@dummy.off(:smth)
|
|
25
|
-
UnderOs::Events::Listeners.all(@dummy, :smth).size.should == 0
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should return the object itself back" do
|
|
29
|
-
@dummy.off(:smth).should.be.same_as @dummy
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe "#emit" do
|
|
34
|
-
it "should emit events" do
|
|
35
|
-
kicked = false
|
|
36
|
-
@dummy.on(:smth) { kicked = true }
|
|
37
|
-
@dummy.emit(:smth)
|
|
38
|
-
kicked.should == true
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should return the object itself back" do
|
|
42
|
-
@dummy.emit(:smth).should.be.same_as @dummy
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should accept optional params" do
|
|
46
|
-
event = nil
|
|
47
|
-
@dummy.on(:smth) { |e| event = e }
|
|
48
|
-
@dummy.emit(:smth, param1: 1, param2: 2)
|
|
49
|
-
event.params.should == {param1: 1, param2: 2}
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe 'UnderOs::Events::Event' do
|
|
54
|
-
before do
|
|
55
|
-
@event = UnderOs::Events::Event.new('event-name', param1: 1, param2: 2)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should give access to it's name" do
|
|
59
|
-
@event.name.should == :"event-name"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should give access to it's params" do
|
|
63
|
-
@event.params.should == {param1: 1, param2: 2}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "should magically pass all the missing requests to the params" do
|
|
67
|
-
@event.param1.should == 1
|
|
68
|
-
@event.param2.should == 2
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
describe UnderOs::File do
|
|
2
|
-
before do
|
|
3
|
-
@existing_path = NSBundle.mainBundle.pathForResource("under-os.css", ofType:nil)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
describe '.exists?' do
|
|
7
|
-
it "returns true for existing files" do
|
|
8
|
-
UnderOs::File.exists?(@existing_path).should == true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "returns false for non existing files" do
|
|
12
|
-
UnderOs::File.exists?("non-existing.file").should == false
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '.size' do
|
|
17
|
-
it "returns file size" do
|
|
18
|
-
UnderOs::File.size(@existing_path).should > 0
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "raises an error when exessing a non-existing file" do
|
|
22
|
-
-> {
|
|
23
|
-
UnderOs::File.size("non-existing.file")
|
|
24
|
-
}.should.raise(StandardError)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe '.read' do
|
|
29
|
-
it "reads files content" do
|
|
30
|
-
content = UnderOs::File.read(@existing_path)
|
|
31
|
-
content.class.should == String
|
|
32
|
-
content.size.should > 0
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "raises an error when read a non-existing file" do
|
|
36
|
-
-> {
|
|
37
|
-
UnderOs::File.read("non-existing.file")
|
|
38
|
-
}.should.raise(StandardError)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe '.write' do
|
|
43
|
-
before do
|
|
44
|
-
UnderOs::File.delete('test.txt')
|
|
45
|
-
@result = UnderOs::File.write('test.txt', 'stuff')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "creates new files" do
|
|
49
|
-
UnderOs::File.exists?('test.txt').should == true
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "writes stuff into files" do
|
|
53
|
-
UnderOs::File.read('test.txt').should == 'stuff'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "overwrites existing files" do
|
|
57
|
-
UnderOs::File.write('test.txt', 'new stuff')
|
|
58
|
-
UnderOs::File.read('test.txt').should == 'new stuff'
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "returns a new File object" do
|
|
62
|
-
@result.class.should == UnderOs::File
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe '.size' do
|
|
67
|
-
it "returns the file size" do
|
|
68
|
-
UnderOs::File.write('test.txt', '12345')
|
|
69
|
-
UnderOs::File.size('test.txt').should == 5
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
describe '.delete' do
|
|
74
|
-
before do
|
|
75
|
-
UnderOs::File.write('test.txt', 'stuff')
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "deletes files" do
|
|
79
|
-
UnderOs::File.delete('test.txt')
|
|
80
|
-
UnderOs::File.exists?('test.txt').should == false
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe '.tmp' do
|
|
85
|
-
before do
|
|
86
|
-
@file = UnderOs::File.tmp("test.txt")
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "creates a new File instance" do
|
|
90
|
-
@file.class.should == UnderOs::File
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "should locate it in the tmp directory" do
|
|
94
|
-
@file.path.to_s.should == "#{NSTemporaryDirectory()}test.txt"
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
describe UnderOS::HTTP::Cookies do
|
|
2
|
-
before do
|
|
3
|
-
@cookies = UnderOS::HTTP::Cookies.new({a: 1, b: true}, "http://test.com")
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
it "allows to export them in a string" do
|
|
7
|
-
@cookies.to_s.should == "a=1; b=true"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "allows to export them into an HTTP header hash" do
|
|
11
|
-
@cookies.headers.should == {"Cookie"=>"a=1; b=true"}
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
describe UnderOS::HTTP::Request do
|
|
2
|
-
before do
|
|
3
|
-
@url = "http://test.com"
|
|
4
|
-
@request = UnderOS::HTTP::Request.new(@url, {
|
|
5
|
-
headers: {my: 'headers'},
|
|
6
|
-
cookies: {my: 'cookies'},
|
|
7
|
-
params: {my: 'params'},
|
|
8
|
-
method: :put
|
|
9
|
-
})
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#constructor" do
|
|
13
|
-
it "assigns the url correctly" do
|
|
14
|
-
@request.url.should == @url
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "assigns the request headers correctly" do
|
|
18
|
-
@request.headers.should == {my: 'headers'}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "assigns the request cookies correctly" do
|
|
22
|
-
@request.cookies.should == {my: 'cookies'}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "assigns my params correctly" do
|
|
26
|
-
@request.params.should == {my: 'params'}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "assigns the request method correctly" do
|
|
30
|
-
@request.method.should == 'PUT'
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe "#on" do
|
|
35
|
-
it "returns the response object instead of an event into a callback" do
|
|
36
|
-
@response = nil
|
|
37
|
-
|
|
38
|
-
@request.on(:smth) { |r| @response = r }
|
|
39
|
-
@request.emit(:smth, response: 'response')
|
|
40
|
-
|
|
41
|
-
@response.should == 'response'
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|