opal-browser 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.yardopts +1 -0
- data/Gemfile +11 -0
- data/README.md +106 -0
- data/Rakefile +5 -0
- data/config.ru +63 -0
- data/lib/opal/browser.rb +4 -0
- data/opal-browser.gemspec +23 -0
- data/opal/browser.rb +10 -0
- data/opal/browser/animation_frame.rb +29 -0
- data/opal/browser/canvas.rb +277 -0
- data/opal/browser/canvas/data.rb +73 -0
- data/opal/browser/canvas/gradient.rb +37 -0
- data/opal/browser/canvas/style.rb +123 -0
- data/opal/browser/canvas/text.rb +55 -0
- data/opal/browser/compatibility.rb +59 -0
- data/opal/browser/compatibility/animation_frame.rb +93 -0
- data/opal/browser/compatibility/dom/document/window.rb +15 -0
- data/opal/browser/compatibility/dom/element/css.rb +15 -0
- data/opal/browser/compatibility/dom/element/matches.rb +31 -0
- data/opal/browser/compatibility/dom/element/offset.rb +20 -0
- data/opal/browser/compatibility/dom/element/scroll.rb +25 -0
- data/opal/browser/compatibility/dom/element/style.rb +15 -0
- data/opal/browser/compatibility/dom/mutation_observer.rb +47 -0
- data/opal/browser/compatibility/http/request.rb +15 -0
- data/opal/browser/compatibility/immediate.rb +107 -0
- data/opal/browser/compatibility/window/scroll.rb +27 -0
- data/opal/browser/compatibility/window/size.rb +13 -0
- data/opal/browser/compatibility/window/view.rb +13 -0
- data/opal/browser/console.rb +137 -0
- data/opal/browser/cookies.rb +79 -0
- data/opal/browser/css.rb +24 -0
- data/opal/browser/css/declaration.rb +88 -0
- data/opal/browser/css/rule.rb +48 -0
- data/opal/browser/css/rule/style.rb +16 -0
- data/opal/browser/css/style_sheet.rb +83 -0
- data/opal/browser/css/unit.rb +188 -0
- data/opal/browser/dom.rb +95 -0
- data/opal/browser/dom/attribute.rb +19 -0
- data/opal/browser/dom/builder.rb +97 -0
- data/opal/browser/dom/cdata.rb +9 -0
- data/opal/browser/dom/character_data.rb +37 -0
- data/opal/browser/dom/comment.rb +9 -0
- data/opal/browser/dom/compatibility.rb +8 -0
- data/opal/browser/dom/document.rb +83 -0
- data/opal/browser/dom/document_fragment.rb +7 -0
- data/opal/browser/dom/element.rb +290 -0
- data/opal/browser/dom/element/input.rb +17 -0
- data/opal/browser/dom/element/offset.rb +67 -0
- data/opal/browser/dom/element/position.rb +37 -0
- data/opal/browser/dom/element/scroll.rb +49 -0
- data/opal/browser/dom/event.rb +240 -0
- data/opal/browser/dom/event/animation.rb +26 -0
- data/opal/browser/dom/event/audio_processing.rb +31 -0
- data/opal/browser/dom/event/base.rb +207 -0
- data/opal/browser/dom/event/before_unload.rb +13 -0
- data/opal/browser/dom/event/clipboard.rb +26 -0
- data/opal/browser/dom/event/close.rb +35 -0
- data/opal/browser/dom/event/composition.rb +38 -0
- data/opal/browser/dom/event/custom.rb +30 -0
- data/opal/browser/dom/event/device_light.rb +21 -0
- data/opal/browser/dom/event/device_motion.rb +38 -0
- data/opal/browser/dom/event/device_orientation.rb +36 -0
- data/opal/browser/dom/event/device_proximity.rb +31 -0
- data/opal/browser/dom/event/drag.rb +113 -0
- data/opal/browser/dom/event/focus.rb +23 -0
- data/opal/browser/dom/event/gamepad.rb +47 -0
- data/opal/browser/dom/event/hash_change.rb +26 -0
- data/opal/browser/dom/event/keyboard.rb +93 -0
- data/opal/browser/dom/event/message.rb +50 -0
- data/opal/browser/dom/event/mouse.rb +253 -0
- data/opal/browser/dom/event/page_transition.rb +21 -0
- data/opal/browser/dom/event/pop_state.rb +21 -0
- data/opal/browser/dom/event/progress.rb +31 -0
- data/opal/browser/dom/event/sensor.rb +13 -0
- data/opal/browser/dom/event/storage.rb +41 -0
- data/opal/browser/dom/event/touch.rb +69 -0
- data/opal/browser/dom/event/ui.rb +22 -0
- data/opal/browser/dom/event/wheel.rb +49 -0
- data/opal/browser/dom/mutation_observer.rb +118 -0
- data/opal/browser/dom/node.rb +317 -0
- data/opal/browser/dom/node_set.rb +88 -0
- data/opal/browser/dom/text.rb +21 -0
- data/opal/browser/effects.rb +39 -0
- data/opal/browser/event_source.rb +67 -0
- data/opal/browser/history.rb +54 -0
- data/opal/browser/http.rb +129 -0
- data/opal/browser/http/binary.rb +57 -0
- data/opal/browser/http/compatibility.rb +1 -0
- data/opal/browser/http/headers.rb +90 -0
- data/opal/browser/http/parameters.rb +8 -0
- data/opal/browser/http/request.rb +331 -0
- data/opal/browser/http/response.rb +115 -0
- data/opal/browser/immediate.rb +43 -0
- data/opal/browser/interval.rb +93 -0
- data/opal/browser/location.rb +77 -0
- data/opal/browser/navigator.rb +151 -0
- data/opal/browser/screen.rb +40 -0
- data/opal/browser/socket.rb +115 -0
- data/opal/browser/storage.rb +149 -0
- data/opal/browser/timeout.rb +60 -0
- data/opal/browser/utils.rb +56 -0
- data/opal/browser/version.rb +3 -0
- data/opal/browser/window.rb +113 -0
- data/opal/browser/window/compatibility.rb +3 -0
- data/opal/browser/window/scroll.rb +49 -0
- data/opal/browser/window/size.rb +35 -0
- data/opal/browser/window/view.rb +18 -0
- data/spec/dom/builder_spec.rb +69 -0
- data/spec/dom/document_spec.rb +40 -0
- data/spec/dom/element_spec.rb +46 -0
- data/spec/dom/event_spec.rb +127 -0
- data/spec/dom/mutation_observer_spec.rb +37 -0
- data/spec/dom/node_spec.rb +154 -0
- data/spec/dom_spec.rb +13 -0
- data/spec/event_source_spec.rb +42 -0
- data/spec/history_spec.rb +48 -0
- data/spec/http_spec.rb +87 -0
- data/spec/immediate_spec.rb +12 -0
- data/spec/json2.js +486 -0
- data/spec/sizzle.js +5 -0
- data/spec/socket_spec.rb +43 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/storage_spec.rb +26 -0
- data/spec/window_spec.rb +10 -0
- metadata +240 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::Builder do
|
4
|
+
it 'builds an element' do
|
5
|
+
DOM {
|
6
|
+
div
|
7
|
+
}.name.should == 'DIV'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'builds an element with text content' do
|
11
|
+
DOM {
|
12
|
+
div "foo bar"
|
13
|
+
}.text.should == "foo bar"
|
14
|
+
|
15
|
+
DOM {
|
16
|
+
div {
|
17
|
+
"foo bar"
|
18
|
+
}
|
19
|
+
}.text.should == "foo bar"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'builds an element with attributes' do
|
23
|
+
DOM {
|
24
|
+
div class: :wut
|
25
|
+
}.class_name.should == :wut
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'builds deeper trees' do
|
29
|
+
res = DOM {
|
30
|
+
div {
|
31
|
+
span {
|
32
|
+
"wut"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
res.name.should == 'DIV'
|
38
|
+
res.child.name.should == 'SPAN'
|
39
|
+
res.child.text.should == 'wut'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'sets classes with methods' do
|
43
|
+
DOM {
|
44
|
+
div.nice.element
|
45
|
+
}.class_names.should == %w[nice element]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'nests when setting classes' do
|
49
|
+
res = DOM {
|
50
|
+
div.nice.element {
|
51
|
+
span.nicer 'lol'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
res.name.should == 'DIV'
|
56
|
+
res.class_names.should == %w[nice element]
|
57
|
+
res.child.name.should == 'SPAN'
|
58
|
+
res.child.class_names.should == %w[nicer]
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'joins class name properly' do
|
62
|
+
res = DOM {
|
63
|
+
i.icon[:legal]
|
64
|
+
}
|
65
|
+
|
66
|
+
res.name.should == 'I'
|
67
|
+
res.class_names.should == %w[icon-legal]
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::Document do
|
4
|
+
describe '#title' do
|
5
|
+
it 'should get the document title' do
|
6
|
+
$document.title.should be_kind_of(String)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#title=' do
|
11
|
+
it 'should set the document title' do
|
12
|
+
old = $document.title
|
13
|
+
$document.title = 'lol'
|
14
|
+
$document.title.should == 'lol'
|
15
|
+
$document.title = old
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
html <<-HTML
|
21
|
+
<div id="lol"></div>
|
22
|
+
HTML
|
23
|
+
|
24
|
+
it "should get element by id" do
|
25
|
+
$document["lol"].should == `#{$document.to_n}.getElementById('lol')`
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get element by css" do
|
29
|
+
$document["lol"].should == `#{$document.to_n}.getElementById('lol')`
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get element by xpath" do
|
33
|
+
$document["//*[@id='lol']"].should == `#{$document.to_n}.getElementById('lol')`
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return nil if it can't find anything" do
|
37
|
+
$document["doo-dah"].should be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::Element do
|
4
|
+
describe '#id' do
|
5
|
+
html <<-HTML
|
6
|
+
<div id="lol"></div>
|
7
|
+
HTML
|
8
|
+
|
9
|
+
it 'gets the proper id' do
|
10
|
+
$document["lol"].id.should == 'lol'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#class_names' do
|
15
|
+
html <<-HTML
|
16
|
+
<div id="class-names">
|
17
|
+
<div id="class-names-1" class="a b c"></div>
|
18
|
+
<div id="class-names-2" class=""></div>
|
19
|
+
</div>
|
20
|
+
HTML
|
21
|
+
|
22
|
+
it 'gives an empty array when no class is set' do
|
23
|
+
$document["class-names-2"].class_names.should == []
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'gives an array of class names' do
|
27
|
+
$document["class-names-1"].class_names.should == %w[a b c]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#matches?' do
|
32
|
+
html <<-HTML
|
33
|
+
<div id="matches" class="not me">
|
34
|
+
<span class="yes me"></span>
|
35
|
+
</div>
|
36
|
+
HTML
|
37
|
+
|
38
|
+
it 'matches on class and id' do
|
39
|
+
$document[:matches].matches?('#matches.not.me').should be_truthy
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'matches on class and name' do
|
43
|
+
$document[:matches].first_element_child.matches?('span.yes').should be_truthy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::Event do
|
4
|
+
html <<-HTML
|
5
|
+
<div id="event-spec">
|
6
|
+
u wot m8
|
7
|
+
</div>
|
8
|
+
HTML
|
9
|
+
|
10
|
+
describe "#on" do
|
11
|
+
it "properly registers an event" do
|
12
|
+
count = 0
|
13
|
+
elem = $document["event-spec"]
|
14
|
+
|
15
|
+
elem.on :click do |event|
|
16
|
+
count += 1
|
17
|
+
end
|
18
|
+
|
19
|
+
count.should == 0
|
20
|
+
elem.trigger :click
|
21
|
+
count.should == 1
|
22
|
+
elem.trigger :click
|
23
|
+
count.should == 2
|
24
|
+
elem.trigger 'mouse:down'
|
25
|
+
count.should == 2
|
26
|
+
end
|
27
|
+
|
28
|
+
it "listens for custom events" do
|
29
|
+
count = 0
|
30
|
+
elem = $document["event-spec"]
|
31
|
+
|
32
|
+
elem.on :huehue do
|
33
|
+
count += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
count.should == 0
|
37
|
+
elem.trigger :huehue
|
38
|
+
count.should == 1
|
39
|
+
elem.trigger :huehue
|
40
|
+
count.should == 2
|
41
|
+
end
|
42
|
+
|
43
|
+
async "passes an event to the handler" do
|
44
|
+
elem = $document["event-spec"]
|
45
|
+
|
46
|
+
elem.on :click do |event|
|
47
|
+
run_async {
|
48
|
+
event.should be_kind_of Browser::DOM::Event
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
elem.trigger :click
|
53
|
+
end
|
54
|
+
|
55
|
+
async "passes additional arguments to the handler" do
|
56
|
+
elem = $document["event-spec"]
|
57
|
+
|
58
|
+
elem.on :bazinga do |event, foo, bar, baz|
|
59
|
+
run_async {
|
60
|
+
foo.should == 1
|
61
|
+
bar.should == 2
|
62
|
+
baz.should == 3
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
elem.trigger :bazinga, 1, 2, 3
|
67
|
+
end
|
68
|
+
|
69
|
+
async "works with deferred elements" do
|
70
|
+
elem = $document["event-spec"]
|
71
|
+
|
72
|
+
elem.on :bazinga, 'span.nami' do
|
73
|
+
run_async {
|
74
|
+
true.should be_truthy
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
elem.add_child DOM { span.nami }
|
79
|
+
|
80
|
+
after 0.01 do
|
81
|
+
elem.first_element_child.trigger :bazinga
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#off" do
|
87
|
+
it "removes all the handlers that were added" do
|
88
|
+
count = 0
|
89
|
+
elem = $document["event-spec"]
|
90
|
+
|
91
|
+
elem.on :click do
|
92
|
+
count += 1
|
93
|
+
end
|
94
|
+
|
95
|
+
elem.on :click do
|
96
|
+
count += 1
|
97
|
+
end
|
98
|
+
|
99
|
+
elem.trigger :click
|
100
|
+
count.should == 2
|
101
|
+
|
102
|
+
elem.off :click
|
103
|
+
elem.trigger :click
|
104
|
+
count.should == 2
|
105
|
+
end
|
106
|
+
|
107
|
+
it "removes only the passed handler" do
|
108
|
+
count = 0
|
109
|
+
elem = $document["event-spec"]
|
110
|
+
|
111
|
+
cb = elem.on :click do
|
112
|
+
count += 1
|
113
|
+
end
|
114
|
+
|
115
|
+
elem.on :click do
|
116
|
+
count += 1
|
117
|
+
end
|
118
|
+
|
119
|
+
elem.trigger :click
|
120
|
+
count.should == 2
|
121
|
+
|
122
|
+
cb.off
|
123
|
+
elem.trigger :click
|
124
|
+
count.should == 3
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::MutationObserver do
|
4
|
+
html <<-HTML
|
5
|
+
<div id="mutate">
|
6
|
+
<span></span>
|
7
|
+
</div>
|
8
|
+
HTML
|
9
|
+
|
10
|
+
async 'notifies additions' do
|
11
|
+
obs = Browser::DOM::MutationObserver.new {|mutations|
|
12
|
+
run_async {
|
13
|
+
mutations.first.added.first.name.should == 'DIV'
|
14
|
+
}
|
15
|
+
|
16
|
+
obs.disconnect
|
17
|
+
}
|
18
|
+
|
19
|
+
obs.observe $document[:mutate]
|
20
|
+
|
21
|
+
$document[:mutate].add_child $document.create_element('div')
|
22
|
+
end
|
23
|
+
|
24
|
+
async 'notifies removals' do
|
25
|
+
obs = Browser::DOM::MutationObserver.new {|mutations|
|
26
|
+
run_async {
|
27
|
+
mutations.first.removed.first.name.should == 'SPAN'
|
28
|
+
}
|
29
|
+
|
30
|
+
obs.disconnect
|
31
|
+
}
|
32
|
+
|
33
|
+
obs.observe $document[:mutate]
|
34
|
+
|
35
|
+
$document[:mutate].first_element_child.remove
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Browser::DOM::Node do
|
4
|
+
describe "#==" do
|
5
|
+
html '<div id="lol"></div>'
|
6
|
+
|
7
|
+
it 'should work when the other argument is the native counterpart' do
|
8
|
+
$document["lol"].should == `document.getElementById("lol")`
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should work when the other argument is the same DOM::Node' do
|
12
|
+
el = $document["lol"]
|
13
|
+
el.should == el
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should work when the other argument is another DOM::Node' do
|
17
|
+
$document["lol"].should == $document["lol"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#document?" do
|
22
|
+
it "should be true for document" do
|
23
|
+
$document.document?.should be_truthy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#element?" do
|
28
|
+
html '<div id="lol"></div>'
|
29
|
+
|
30
|
+
it "should be true for <div id='lol'>" do
|
31
|
+
$document["#lol"].element?.should be_truthy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#text?" do
|
36
|
+
html '<div id="omg">lol</div>'
|
37
|
+
|
38
|
+
it "should be true for the first child of <div id='lol'>" do
|
39
|
+
$document["#omg"].child.text?.should be_truthy
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#ancestors" do
|
44
|
+
html <<-HTML
|
45
|
+
<div><span><strong><em id="incest"></em></strong></span></div>
|
46
|
+
HTML
|
47
|
+
|
48
|
+
it 'should get all ancestors' do
|
49
|
+
ancestors = $document["incest"].ancestors
|
50
|
+
|
51
|
+
ancestors[0].name.should == 'STRONG'
|
52
|
+
ancestors[1].name.should == 'SPAN'
|
53
|
+
ancestors[2].name.should == 'DIV'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should get only the selected ancestors' do
|
57
|
+
$document["incest"].ancestors('strong').length.should == 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#child' do
|
62
|
+
html <<-HTML
|
63
|
+
<div id="test-1"><div id="test-2"></div></div>
|
64
|
+
HTML
|
65
|
+
|
66
|
+
it 'gets the first child properly' do
|
67
|
+
$document["test-1"].child.id.should == "test-2"
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns nil if there is no child' do
|
71
|
+
$document["test-2"].child.should be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#next' do
|
76
|
+
html <<-HTML
|
77
|
+
<div id="spec-1"></div>
|
78
|
+
<div id="spec-2"></div>
|
79
|
+
<div id="spec-3"></div>
|
80
|
+
HTML
|
81
|
+
|
82
|
+
it 'should return the next sibling' do
|
83
|
+
$document["spec-1"].next.text?.should be_truthy
|
84
|
+
$document["spec-1"].next.next.id.should == 'spec-2'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return nil when there is no next sibling' do
|
88
|
+
$document["spec-3"].next.text?.should be_truthy
|
89
|
+
$document["spec-3"].next.next.should be_nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#next_element' do
|
94
|
+
html <<-HTML
|
95
|
+
<div id="spec-1"></div>
|
96
|
+
<div id="spec-2"></div>
|
97
|
+
<div id="spec-3"></div>
|
98
|
+
HTML
|
99
|
+
|
100
|
+
it 'should return the next element sibling' do
|
101
|
+
$document["spec-1"].next_element.id.should == 'spec-2'
|
102
|
+
$document["spec-2"].next_element.id.should == 'spec-3'
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should return nil when there is no next element sibling' do
|
106
|
+
$document["spec-3"].next_element.should be_nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#previous' do
|
111
|
+
html <<-HTML
|
112
|
+
<div id="spec-1"></div>
|
113
|
+
<div id="spec-2"></div>
|
114
|
+
<div id="spec-3"></div>
|
115
|
+
HTML
|
116
|
+
|
117
|
+
it 'should return the previous sibling' do
|
118
|
+
$document["spec-2"].previous.text?.should be_truthy
|
119
|
+
$document["spec-2"].previous.previous.id.should == 'spec-1'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should return nil when there is no previous sibling' do
|
123
|
+
$document["spec-1"].previous.text?.should be_truthy
|
124
|
+
$document["spec-1"].previous.previous.should be_nil
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#previous_element' do
|
129
|
+
html <<-HTML
|
130
|
+
<div id="spec-1"></div>
|
131
|
+
<div id="spec-2"></div>
|
132
|
+
<div id="spec-3"></div>
|
133
|
+
HTML
|
134
|
+
|
135
|
+
it 'should return the previous element sibling' do
|
136
|
+
$document["spec-2"].previous_element.id.should == 'spec-1'
|
137
|
+
$document["spec-3"].previous_element.id.should == 'spec-2'
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should return nil when there is no previous element sibling' do
|
141
|
+
$document["spec-1"].previous_element.should be_nil
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#inner_text' do
|
146
|
+
html <<-HTML
|
147
|
+
<div id="inner"><span>I like trains.</span> <span>And turtles.</span></div>
|
148
|
+
HTML
|
149
|
+
|
150
|
+
it 'should get the whole text for elements' do
|
151
|
+
$document["inner"].inner_text.should == "I like trains. And turtles."
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|