capybara 0.3.0 → 0.3.5
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.
- data/Manifest.txt +4 -0
- data/README.rdoc +45 -5
- data/lib/capybara.rb +11 -4
- data/lib/capybara/driver/base.rb +3 -0
- data/lib/capybara/driver/celerity_driver.rb +44 -9
- data/lib/capybara/driver/rack_test_driver.rb +80 -16
- data/lib/capybara/driver/selenium_driver.rb +41 -9
- data/lib/capybara/dsl.rb +4 -10
- data/lib/capybara/node.rb +8 -0
- data/lib/capybara/rails.rb +8 -2
- data/lib/capybara/save_and_open_page.rb +5 -1
- data/lib/capybara/searchable.rb +17 -9
- data/lib/capybara/server.rb +35 -23
- data/lib/capybara/session.rb +91 -22
- data/lib/capybara/xpath.rb +66 -27
- data/spec/driver/celerity_driver_spec.rb +2 -2
- data/spec/driver/culerity_driver_spec.rb +1 -2
- data/spec/driver/rack_test_driver_spec.rb +0 -1
- data/spec/driver/remote_culerity_driver_spec.rb +9 -5
- data/spec/driver/selenium_driver_spec.rb +0 -1
- data/spec/drivers_spec.rb +24 -32
- data/spec/dsl/all_spec.rb +56 -25
- data/spec/dsl/attach_file_spec.rb +49 -51
- data/spec/dsl/check_spec.rb +12 -1
- data/spec/dsl/choose_spec.rb +19 -21
- data/spec/dsl/click_button_spec.rb +140 -87
- data/spec/dsl/click_link_spec.rb +88 -68
- data/spec/dsl/click_spec.rb +20 -22
- data/spec/dsl/current_url_spec.rb +6 -8
- data/spec/dsl/fill_in_spec.rb +75 -67
- data/spec/dsl/find_button_spec.rb +12 -14
- data/spec/dsl/find_by_id_spec.rb +16 -0
- data/spec/dsl/find_field_spec.rb +17 -19
- data/spec/dsl/find_link_spec.rb +13 -15
- data/spec/dsl/find_spec.rb +44 -23
- data/spec/dsl/has_button_spec.rb +32 -0
- data/spec/dsl/has_content_spec.rb +79 -81
- data/spec/dsl/has_css_spec.rb +81 -83
- data/spec/dsl/has_field_spec.rb +96 -0
- data/spec/dsl/has_link_spec.rb +33 -0
- data/spec/dsl/has_xpath_spec.rb +97 -89
- data/spec/dsl/locate_spec.rb +47 -26
- data/spec/dsl/select_spec.rb +61 -17
- data/spec/dsl/uncheck_spec.rb +17 -25
- data/spec/dsl/within_spec.rb +112 -104
- data/spec/public/test.js +3 -0
- data/spec/searchable_spec.rb +1 -1
- data/spec/server_spec.rb +7 -7
- data/spec/session/celerity_session_spec.rb +2 -2
- data/spec/session/culerity_session_spec.rb +1 -1
- data/spec/session_spec.rb +7 -0
- data/spec/session_with_javascript_support_spec.rb +139 -120
- data/spec/spec_helper.rb +7 -2
- data/spec/test_app.rb +8 -4
- data/spec/views/form.erb +50 -2
- data/spec/views/tables.erb +61 -1
- data/spec/views/with_html.erb +8 -2
- data/spec/views/with_js.erb +4 -0
- data/spec/xpath_spec.rb +17 -0
- metadata +6 -2
data/spec/spec_helper.rb
CHANGED
@@ -10,7 +10,6 @@ require 'drivers_spec'
|
|
10
10
|
require 'session_spec'
|
11
11
|
Dir[File.dirname(__FILE__)+'/dsl/*'].each { |group|
|
12
12
|
require group
|
13
|
-
include Object.const_get(group.match(/.*[\/]{1}([\w]*)[.rb]./).captures.first.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase })
|
14
13
|
}
|
15
14
|
require 'session_with_javascript_support_spec'
|
16
15
|
require 'session_without_javascript_support_spec'
|
@@ -19,4 +18,10 @@ require 'session_without_headers_support_spec'
|
|
19
18
|
|
20
19
|
alias :running :lambda
|
21
20
|
|
22
|
-
Capybara.default_wait_time =
|
21
|
+
Capybara.default_wait_time = 0 # less timeout so tests run faster
|
22
|
+
|
23
|
+
Spec::Runner.configure do |config|
|
24
|
+
config.after do
|
25
|
+
Capybara.default_selector = :xpath
|
26
|
+
end
|
27
|
+
end
|
data/spec/test_app.rb
CHANGED
@@ -38,14 +38,18 @@ class TestApp < Sinatra::Base
|
|
38
38
|
nil
|
39
39
|
end
|
40
40
|
|
41
|
-
get '/:view' do |view|
|
42
|
-
erb view.to_sym
|
43
|
-
end
|
44
|
-
|
45
41
|
post '/redirect' do
|
46
42
|
redirect '/redirect_again'
|
47
43
|
end
|
48
44
|
|
45
|
+
get '/redirect_back' do
|
46
|
+
redirect back
|
47
|
+
end
|
48
|
+
|
49
|
+
get '/:view' do |view|
|
50
|
+
erb view.to_sym
|
51
|
+
end
|
52
|
+
|
49
53
|
post '/form' do
|
50
54
|
'<pre id="results">' + params[:form].to_yaml + '</pre>'
|
51
55
|
end
|
data/spec/views/form.erb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
<h1>Form</h1>
|
2
2
|
|
3
3
|
<form action="/form" method="post">
|
4
|
+
|
5
|
+
<p>
|
6
|
+
<label for="form_title">Title</label>
|
7
|
+
<select name="form[title]" id="form_title">
|
8
|
+
<option>Mrs</option>
|
9
|
+
<option>Mr</option>
|
10
|
+
<option>Miss</option>
|
11
|
+
</select>
|
12
|
+
</p>
|
13
|
+
|
4
14
|
<p>
|
5
15
|
<label for="form_first_name">
|
6
16
|
First Name
|
@@ -12,6 +22,11 @@
|
|
12
22
|
<label for="form_last_name">Last Name</label>
|
13
23
|
<input type="text" name="form[last_name]" value="Smith" id="form_last_name"/>
|
14
24
|
</p>
|
25
|
+
|
26
|
+
<p>
|
27
|
+
<label for="form_name_explanation">Explanation of Name</label>
|
28
|
+
<textarea name="form[name_explanation]" id="form_name_explanation"></textarea>
|
29
|
+
</p>
|
15
30
|
|
16
31
|
<p>
|
17
32
|
<label for="form_name">Name</label>
|
@@ -106,10 +121,39 @@
|
|
106
121
|
</p>
|
107
122
|
|
108
123
|
<p>
|
124
|
+
<label for="form_languages">Languages</label>
|
125
|
+
<select name="form[languages][]" id="form_languages" multiple="multiple">
|
126
|
+
<option>Ruby</option>
|
127
|
+
<option>SQL</option>
|
128
|
+
<option>HTML</option>
|
129
|
+
<option>Javascript</option>
|
130
|
+
</select>
|
131
|
+
</p>
|
132
|
+
|
133
|
+
<p>
|
134
|
+
<label for="form_underwear">Underwear</label>
|
135
|
+
<select name="form[underwear][]" id="form_underwear" multiple="multiple">
|
136
|
+
<option selected="selected">Boxer Briefs</option>
|
137
|
+
<option>Boxers</option>
|
138
|
+
<option selected="selected">Briefs</option>
|
139
|
+
<option selected="selected">Commando</option>
|
140
|
+
</select>
|
141
|
+
</p>
|
142
|
+
|
143
|
+
<div style="display:none;">
|
144
|
+
<label for="form_first_name_hidden">
|
145
|
+
Super Secret
|
146
|
+
<input type="text" name="form[super_secret]" value="test123" id="form_super_secret"/>
|
147
|
+
</label>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<p>
|
151
|
+
<input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
|
109
152
|
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
110
153
|
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
111
|
-
<input type="image" name="form[okay]" id="okay556" value="okay"/>
|
154
|
+
<input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
|
112
155
|
<button type="submit" id="click_me_123" value="click_me">Click me!</button>
|
156
|
+
<button type="submit" name="form[no_value]">No Value!</button>
|
113
157
|
</p>
|
114
158
|
</form>
|
115
159
|
|
@@ -167,6 +211,10 @@
|
|
167
211
|
<label for="html5_color">Html5 Color</label>
|
168
212
|
<input type="color" name="form[html5_color]" value="#FFF" id="html5_color"/>
|
169
213
|
</p>
|
214
|
+
|
215
|
+
<p>
|
216
|
+
<input type="submit" name="form[html5_submit]" value="html5_submit"/>
|
217
|
+
</p>
|
170
218
|
</form>
|
171
219
|
|
172
220
|
<form action="/form" method="post">
|
@@ -176,4 +224,4 @@
|
|
176
224
|
<input type="submit" name="form[button]" value="Just a button that came first"/>
|
177
225
|
<input type="submit" name="form[button]" value="Just a button"/>
|
178
226
|
</p>
|
179
|
-
</form>
|
227
|
+
</form>
|
data/spec/views/tables.erb
CHANGED
@@ -59,4 +59,64 @@
|
|
59
59
|
</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
|
-
</form>
|
62
|
+
</form>
|
63
|
+
|
64
|
+
<table>
|
65
|
+
<caption>Ransom</caption>
|
66
|
+
|
67
|
+
<thead>
|
68
|
+
<tr>
|
69
|
+
<th>Year</th>
|
70
|
+
<th>Governmental</th>
|
71
|
+
<th>Private</th>
|
72
|
+
</tr>
|
73
|
+
</thead>
|
74
|
+
|
75
|
+
<tbody>
|
76
|
+
<tr>
|
77
|
+
<th scope="row">2007</th>
|
78
|
+
<td>$300</td>
|
79
|
+
<td>$100</td>
|
80
|
+
</tr>
|
81
|
+
<tr>
|
82
|
+
<th scope="row">2008</th>
|
83
|
+
<td>$123</td>
|
84
|
+
<td>$897</td>
|
85
|
+
</tr>
|
86
|
+
<tr>
|
87
|
+
<th scope="row">2009</th>
|
88
|
+
<td>$543</td>
|
89
|
+
<td>$99</td>
|
90
|
+
</tr>
|
91
|
+
</tbody>
|
92
|
+
</table>
|
93
|
+
|
94
|
+
<table>
|
95
|
+
<caption>Deaths</caption>
|
96
|
+
|
97
|
+
<thead>
|
98
|
+
<tr>
|
99
|
+
<th>Year</th>
|
100
|
+
<th>Sharks with lasers</th>
|
101
|
+
<th>Flaming volcano</th>
|
102
|
+
</tr>
|
103
|
+
</thead>
|
104
|
+
|
105
|
+
<tbody>
|
106
|
+
<tr>
|
107
|
+
<th scope="row">2007</th>
|
108
|
+
<td>66</td>
|
109
|
+
<td>7</td>
|
110
|
+
</tr>
|
111
|
+
<tr>
|
112
|
+
<th scope="row">2008</th>
|
113
|
+
<td>123</td>
|
114
|
+
<td>12</td>
|
115
|
+
</tr>
|
116
|
+
<tr>
|
117
|
+
<th scope="row">2009</th>
|
118
|
+
<td>913</td>
|
119
|
+
<td>13</td>
|
120
|
+
</tr>
|
121
|
+
</tbody>
|
122
|
+
</table>
|
data/spec/views/with_html.erb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
et dolore magna aliqua. Ut enim ad minim veniam,
|
7
7
|
quis nostrud exercitation <a href="/foo" id="foo">ullamco</a> laboris nisi
|
8
8
|
ut aliquip ex ea commodo consequat.
|
9
|
+
<a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="awesome image" /></a>
|
9
10
|
</p>
|
10
11
|
|
11
12
|
<p id="second">
|
@@ -16,6 +17,7 @@
|
|
16
17
|
|
17
18
|
<p>
|
18
19
|
<input type="text" id="test_field" value="monkey"/>
|
20
|
+
<a href="/redirect_back">BackToMyself</a>
|
19
21
|
<a title="twas a fine link" href="/redirect">A link came first</a>
|
20
22
|
<a title="a fine link" href="/with_simple_html">A link</a>
|
21
23
|
<a>No Href</a>
|
@@ -25,8 +27,12 @@
|
|
25
27
|
<a href="/with_simple_html#anchor">Anchor on different page</a>
|
26
28
|
<a href="/with_html#anchor">Anchor on same page</a>
|
27
29
|
<input type="text" value="" id="test_field">
|
30
|
+
<input type="text" checked="checked" id="checked_field">
|
31
|
+
<a href="/redirect"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="very fine image" /></a>
|
32
|
+
<a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="fine image" /></a>
|
28
33
|
</p>
|
29
34
|
|
30
|
-
<div id="hidden" style="display:none;">
|
35
|
+
<div id="hidden" style="display: none;">
|
31
36
|
<div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
|
32
|
-
</
|
37
|
+
<a href="/with_simple_html" title="awesome title" class="simple">hidden link</a>
|
38
|
+
</div>
|
data/spec/views/with_js.erb
CHANGED
data/spec/xpath_spec.rb
CHANGED
@@ -155,6 +155,23 @@ describe Capybara::XPath do
|
|
155
155
|
@driver.find(@query).first.value.should == 'seeekrit'
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
describe '#button' do
|
160
|
+
it "should find a button by id or content" do
|
161
|
+
@query = @xpath.button('awe123').to_s
|
162
|
+
@driver.find(@query).first.value.should == 'awesome'
|
163
|
+
@query = @xpath.button('okay556').to_s
|
164
|
+
@driver.find(@query).first.value.should == 'okay'
|
165
|
+
@query = @xpath.button('click_me_123').to_s
|
166
|
+
@driver.find(@query).first.value.should == 'click_me'
|
167
|
+
@query = @xpath.button('Click me!').to_s
|
168
|
+
@driver.find(@query).first.value.should == 'click_me'
|
169
|
+
@query = @xpath.button('fresh_btn').to_s
|
170
|
+
@driver.find(@query).first.value.should == 'i am fresh'
|
171
|
+
@query = @xpath.button('i am fresh').to_s
|
172
|
+
@driver.find(@query).first[:name].should == 'form[fresh]'
|
173
|
+
end
|
174
|
+
end
|
158
175
|
|
159
176
|
describe '#radio_button' do
|
160
177
|
it "should find a radio button by id or label" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-26 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -161,11 +161,15 @@ files:
|
|
161
161
|
- spec/dsl/current_url_spec.rb
|
162
162
|
- spec/dsl/fill_in_spec.rb
|
163
163
|
- spec/dsl/find_button_spec.rb
|
164
|
+
- spec/dsl/find_by_id_spec.rb
|
164
165
|
- spec/dsl/find_field_spec.rb
|
165
166
|
- spec/dsl/find_link_spec.rb
|
166
167
|
- spec/dsl/find_spec.rb
|
168
|
+
- spec/dsl/has_button_spec.rb
|
167
169
|
- spec/dsl/has_content_spec.rb
|
168
170
|
- spec/dsl/has_css_spec.rb
|
171
|
+
- spec/dsl/has_field_spec.rb
|
172
|
+
- spec/dsl/has_link_spec.rb
|
169
173
|
- spec/dsl/has_xpath_spec.rb
|
170
174
|
- spec/dsl/locate_spec.rb
|
171
175
|
- spec/dsl/select_spec.rb
|