capybara-mechanize 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/capybara/driver/mechanize.rb +24 -10
- data/lib/capybara/spec/extended_test_app.rb +96 -0
- data/lib/capybara/spec/views/buttons.erb +4 -0
- data/lib/capybara/spec/views/fieldsets.erb +29 -0
- data/lib/capybara/spec/views/form.erb +245 -0
- data/lib/capybara/spec/views/frame_one.erb +8 -0
- data/lib/capybara/spec/views/frame_two.erb +8 -0
- data/lib/capybara/spec/views/postback.erb +13 -0
- data/lib/capybara/spec/views/tables.erb +122 -0
- data/lib/capybara/spec/views/with_html.erb +43 -0
- data/lib/capybara/spec/views/with_js.erb +39 -0
- data/lib/capybara/spec/views/with_scope.erb +36 -0
- data/lib/capybara/spec/views/with_simple_html.erb +1 -0
- data/lib/capybara/spec/views/within_frames.erb +10 -0
- data/spec/driver/mechanize_driver_spec.rb +1 -2
- data/spec/driver/remote_mechanize_driver_spec.rb +8 -6
- data/spec/session/remote_mechanize_spec.rb +47 -0
- metadata +17 -3
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'mechanize'
|
2
2
|
|
3
3
|
class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
def_delegator :agent, :scheme_handlers
|
7
|
+
def_delegator :agent, :scheme_handlers=
|
4
8
|
|
5
9
|
def initialize(*args)
|
6
10
|
super
|
7
11
|
@agent = ::Mechanize.new
|
8
12
|
@agent.redirect_ok = false
|
9
13
|
end
|
10
|
-
|
14
|
+
|
11
15
|
def visit(url)
|
12
16
|
get url
|
13
17
|
end
|
@@ -18,24 +22,25 @@ class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
|
|
18
22
|
end
|
19
23
|
|
20
24
|
def current_url
|
21
|
-
|
25
|
+
last_request_remote? ? remote_response.current_url : super
|
22
26
|
end
|
23
27
|
|
24
28
|
def response
|
25
|
-
|
29
|
+
last_request_remote? ? remote_response : super
|
26
30
|
end
|
27
|
-
|
31
|
+
|
28
32
|
# TODO see how this can be cleaned up
|
29
33
|
def follow_redirect!
|
30
34
|
unless response.redirect?
|
31
35
|
raise "Last response was not a redirect. Cannot follow_redirect!"
|
32
36
|
end
|
33
37
|
|
34
|
-
if
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
location = if last_request_remote?
|
39
|
+
remote_response.page.response['Location']
|
40
|
+
else
|
41
|
+
response['Location']
|
42
|
+
end
|
43
|
+
|
39
44
|
get(location)
|
40
45
|
end
|
41
46
|
|
@@ -59,18 +64,27 @@ class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
|
|
59
64
|
end
|
60
65
|
|
61
66
|
private
|
67
|
+
|
68
|
+
attr_reader :agent
|
69
|
+
|
70
|
+
def last_request_remote?
|
71
|
+
!!@last_request_remote
|
72
|
+
end
|
62
73
|
|
63
74
|
def process_remote_request(method, url, *options)
|
64
75
|
if remote?(url)
|
65
76
|
url = File.join((Capybara.app_host || Capybara.default_host), url) if URI.parse(url).host.nil?
|
66
77
|
reset_cache
|
67
78
|
@agent.send *( [method, url] + options)
|
79
|
+
@last_request_remote = true
|
68
80
|
follow_redirects!
|
69
81
|
true
|
82
|
+
else
|
83
|
+
@last_request_remote = false
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
73
|
-
def
|
87
|
+
def remote_response
|
74
88
|
ResponseProxy.new(@agent.current_page) if @agent.current_page
|
75
89
|
end
|
76
90
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
# require 'rack'
|
4
|
+
# require 'yaml'
|
5
|
+
|
6
|
+
class TestApp < Sinatra::Base
|
7
|
+
set :root, File.dirname(__FILE__)
|
8
|
+
set :static, true
|
9
|
+
|
10
|
+
get '/' do
|
11
|
+
'Hello world!'
|
12
|
+
end
|
13
|
+
|
14
|
+
get '/foo' do
|
15
|
+
'Another World'
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/redirect' do
|
19
|
+
redirect '/redirect_again'
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/redirect_again' do
|
23
|
+
redirect '/landed'
|
24
|
+
end
|
25
|
+
|
26
|
+
get '/redirect/:times/times' do
|
27
|
+
times = params[:times].to_i
|
28
|
+
if times.zero?
|
29
|
+
"redirection complete"
|
30
|
+
else
|
31
|
+
redirect "/redirect/#{times - 1}/times"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/landed' do
|
36
|
+
"You landed"
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/with-quotes' do
|
40
|
+
%q{"No," he said, "you can't do that."}
|
41
|
+
end
|
42
|
+
|
43
|
+
get '/form/get' do
|
44
|
+
'<pre id="results">' + params[:form].to_yaml + '</pre>'
|
45
|
+
end
|
46
|
+
|
47
|
+
get '/favicon.ico' do
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
post '/redirect' do
|
52
|
+
redirect '/redirect_again'
|
53
|
+
end
|
54
|
+
|
55
|
+
delete "/delete" do
|
56
|
+
"The requested object was deleted"
|
57
|
+
end
|
58
|
+
|
59
|
+
get '/redirect_back' do
|
60
|
+
redirect back
|
61
|
+
end
|
62
|
+
|
63
|
+
get '/set_cookie' do
|
64
|
+
cookie_value = 'test_cookie'
|
65
|
+
response.set_cookie('capybara', cookie_value)
|
66
|
+
"Cookie set to #{cookie_value}"
|
67
|
+
end
|
68
|
+
|
69
|
+
get '/get_cookie' do
|
70
|
+
request.cookies['capybara']
|
71
|
+
end
|
72
|
+
|
73
|
+
get '/:view' do |view|
|
74
|
+
erb view.to_sym
|
75
|
+
end
|
76
|
+
|
77
|
+
post '/form' do
|
78
|
+
'<pre id="results">' + params[:form].to_yaml + '</pre>'
|
79
|
+
end
|
80
|
+
|
81
|
+
post '/upload' do
|
82
|
+
begin
|
83
|
+
buffer = []
|
84
|
+
buffer << "Content-type: #{params[:form][:document][:type]}"
|
85
|
+
buffer << "File content: #{params[:form][:document][:tempfile].read}"
|
86
|
+
buffer.join(' | ')
|
87
|
+
rescue
|
88
|
+
'No file uploaded'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# if __FILE__ == $0
|
94
|
+
# Rack::Handler::Mongrel.run TestApp, :Port => 8070
|
95
|
+
# end
|
96
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<form action="/form" method="post">
|
2
|
+
<fieldset id="agent_fieldset">
|
3
|
+
<legend>Agent</legend>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
<label for="form_agent_name">Name</label>
|
7
|
+
<input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<input type="submit" value="Create"/>
|
12
|
+
</p>
|
13
|
+
</fieldset>
|
14
|
+
</form>
|
15
|
+
|
16
|
+
<form action="/form" method="post">
|
17
|
+
<fieldset id="villain_fieldset">
|
18
|
+
<legend>Villain</legend>
|
19
|
+
|
20
|
+
<p>
|
21
|
+
<label for="form_villain_name">Name</label>
|
22
|
+
<input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
|
23
|
+
</p>
|
24
|
+
|
25
|
+
<p>
|
26
|
+
<input type="submit" value="Create"/>
|
27
|
+
</p>
|
28
|
+
</fieldset>
|
29
|
+
</form>
|
@@ -0,0 +1,245 @@
|
|
1
|
+
<h1>Form</h1>
|
2
|
+
|
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
|
+
|
14
|
+
|
15
|
+
<p>
|
16
|
+
<label for="form_other_title">Other title</label>
|
17
|
+
<select name="form[other_title]" id="form_other_title">
|
18
|
+
<option>Mrs</option>
|
19
|
+
<option>Mr</option>
|
20
|
+
<option>Miss</option>
|
21
|
+
</select>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<p>
|
25
|
+
<label for="form_first_name">
|
26
|
+
First Name
|
27
|
+
<input type="text" name="form[first_name]" value="John" id="form_first_name"/>
|
28
|
+
</label>
|
29
|
+
</p>
|
30
|
+
|
31
|
+
<p>
|
32
|
+
<label for="form_last_name">Last Name</label>
|
33
|
+
<input type="text" name="form[last_name]" value="Smith" id="form_last_name"/>
|
34
|
+
</p>
|
35
|
+
|
36
|
+
<p>
|
37
|
+
<label for="form_name_explanation">Explanation of Name</label>
|
38
|
+
<textarea name="form[name_explanation]" id="form_name_explanation"></textarea>
|
39
|
+
</p>
|
40
|
+
|
41
|
+
<p>
|
42
|
+
<label for="form_name">Name</label>
|
43
|
+
<input type="text" name="form[name]" value="John Smith" id="form_name"/>
|
44
|
+
</p>
|
45
|
+
|
46
|
+
<p>
|
47
|
+
<label for="form_schmooo">Schmooo</label>
|
48
|
+
<input type="schmooo" name="form[schmooo]" value="This is Schmooo!" id="form_schmooo"/>
|
49
|
+
</p>
|
50
|
+
|
51
|
+
<p>
|
52
|
+
<label>Street<br/>
|
53
|
+
<input type="text" name="form[street]" value="Sesame street 66"/>
|
54
|
+
</label>
|
55
|
+
</p>
|
56
|
+
|
57
|
+
<p>
|
58
|
+
<label for="form_phone">Phone</label>
|
59
|
+
<input name="form[phone]" value="+1 555 7021" id="form_phone"/>
|
60
|
+
</p>
|
61
|
+
|
62
|
+
<p>
|
63
|
+
<label for="form_password">Password</label>
|
64
|
+
<input type="password" name="form[password]" value="seeekrit" id="form_password"/>
|
65
|
+
</p>
|
66
|
+
|
67
|
+
<p>
|
68
|
+
<label for="form_terms_of_use">Terms of Use</label>
|
69
|
+
<input type="hidden" name="form[terms_of_use]" value="0" id="form_terms_of_use_default">
|
70
|
+
<input type="checkbox" name="form[terms_of_use]" value="1" id="form_terms_of_use">
|
71
|
+
</p>
|
72
|
+
|
73
|
+
<p>
|
74
|
+
<label for="form_image">Image</label>
|
75
|
+
<input type="file" name="form[image]" id="form_image"/>
|
76
|
+
</p>
|
77
|
+
|
78
|
+
<p>
|
79
|
+
<input type="hidden" name="form[token]" value="12345" id="form_token"/>
|
80
|
+
</p>
|
81
|
+
|
82
|
+
<p>
|
83
|
+
<label for="form_locale">Locale</label>
|
84
|
+
<select name="form[locale]" id="form_locale">
|
85
|
+
<option value="sv">Swedish</option>
|
86
|
+
<option selected="selected" value="en">English</option>
|
87
|
+
<option value="fi">Finish</option>
|
88
|
+
<option value="no">Norwegian</option>
|
89
|
+
<option value="jo">John's made-up language</option>
|
90
|
+
<option value="jbo"> Lojban </option>
|
91
|
+
</select>
|
92
|
+
</p>
|
93
|
+
|
94
|
+
<p>
|
95
|
+
<label for="form_region">Region</label>
|
96
|
+
<select name="form[region]" id="form_region">
|
97
|
+
<option>Sweden</option>
|
98
|
+
<option selected="selected">Norway</option>
|
99
|
+
<option>Finland</option>
|
100
|
+
</select>
|
101
|
+
</p>
|
102
|
+
|
103
|
+
<p>
|
104
|
+
<label for="form_city">City</label>
|
105
|
+
<select name="form[city]" id="form_city">
|
106
|
+
<option>London</option>
|
107
|
+
<option>Stockholm</option>
|
108
|
+
<option>Paris</option>
|
109
|
+
</select>
|
110
|
+
</p>
|
111
|
+
|
112
|
+
<p>
|
113
|
+
<label for="form_tendency">Tendency</label>
|
114
|
+
<select name="form[tendency]" id="form_tendency"></select>
|
115
|
+
</p>
|
116
|
+
|
117
|
+
<p>
|
118
|
+
<label for="form_description">Description</label></br>
|
119
|
+
<textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
|
120
|
+
<p>
|
121
|
+
|
122
|
+
<p>
|
123
|
+
<input type="radio" name="form[gender]" value="male" id="gender_male"/>
|
124
|
+
<label for="gender_male">Male</label>
|
125
|
+
<input type="radio" name="form[gender]" value="female" id="gender_female" checked="checked"/>
|
126
|
+
<label for="gender_female">Female</label>
|
127
|
+
<input type="radio" name="form[gender]" value="both" id="gender_both"/>
|
128
|
+
<label for="gender_both">Both</label>
|
129
|
+
</p>
|
130
|
+
|
131
|
+
<p>
|
132
|
+
<input type="checkbox" value="dog" name="form[pets][]" id="form_pets_dog" checked="checked"/>
|
133
|
+
<label for="form_pets_dog">Dog</label>
|
134
|
+
<input type="checkbox" value="cat" name="form[pets][]" id="form_pets_cat"/>
|
135
|
+
<label for="form_pets_cat">Cat</label>
|
136
|
+
<input type="checkbox" value="hamster" name="form[pets][]" id="form_pets_hamster" checked="checked"/>
|
137
|
+
<label for="form_pets_hamster">Hamster</label>
|
138
|
+
</p>
|
139
|
+
|
140
|
+
<p>
|
141
|
+
<label for="form_languages">Languages</label>
|
142
|
+
<select name="form[languages][]" id="form_languages" multiple="multiple">
|
143
|
+
<option>Ruby</option>
|
144
|
+
<option>SQL</option>
|
145
|
+
<option>HTML</option>
|
146
|
+
<option>Javascript</option>
|
147
|
+
</select>
|
148
|
+
</p>
|
149
|
+
|
150
|
+
<p>
|
151
|
+
<label for="form_underwear">Underwear</label>
|
152
|
+
<select name="form[underwear][]" id="form_underwear" multiple="multiple">
|
153
|
+
<option selected="selected">Boxer Briefs</option>
|
154
|
+
<option>Boxers</option>
|
155
|
+
<option selected="selected">Briefs</option>
|
156
|
+
<option selected="selected">Commando</option>
|
157
|
+
<option selected="selected">Frenchman's Pantalons</option>
|
158
|
+
</select>
|
159
|
+
</p>
|
160
|
+
|
161
|
+
<div style="display:none;">
|
162
|
+
<label for="form_first_name_hidden">
|
163
|
+
Super Secret
|
164
|
+
<input type="text" name="form[super_secret]" value="test123" id="form_super_secret"/>
|
165
|
+
</label>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<p>
|
169
|
+
<input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
|
170
|
+
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
171
|
+
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
172
|
+
<input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
|
173
|
+
<button type="submit" id="click_me_123" value="click_me">Click me!</button>
|
174
|
+
<button type="submit" name="form[no_value]">No Value!</button>
|
175
|
+
</p>
|
176
|
+
</form>
|
177
|
+
|
178
|
+
<form action="/form/get?foo=bar" method="get">
|
179
|
+
<p>
|
180
|
+
<label for="form_middle_name">Middle Name</label>
|
181
|
+
<input type="text" name="form[middle_name]" value="Darren" id="form_middle_name"/>
|
182
|
+
</p>
|
183
|
+
|
184
|
+
<p>
|
185
|
+
<input type="submit" name="form[mediocre]" id="mediocre" value="med"/>
|
186
|
+
<p>
|
187
|
+
</form>
|
188
|
+
|
189
|
+
<form action="/upload" method="post" enctype="multipart/form-data">
|
190
|
+
<p>
|
191
|
+
<label for="form_file_name">File Name</label>
|
192
|
+
<input type="file" name="form[file_name]" id="form_file_name"/>
|
193
|
+
</p>
|
194
|
+
|
195
|
+
<p>
|
196
|
+
<label for="form_document">Document</label>
|
197
|
+
<input type="file" name="form[document]" id="form_document"/>
|
198
|
+
</p>
|
199
|
+
|
200
|
+
<p>
|
201
|
+
<input type="submit" value="Upload"/>
|
202
|
+
<p>
|
203
|
+
</form>
|
204
|
+
|
205
|
+
<form action="/redirect" method="post">
|
206
|
+
<p>
|
207
|
+
<input type="submit" value="Go FAR"/>
|
208
|
+
</p>
|
209
|
+
</form>
|
210
|
+
|
211
|
+
<form action="/form" method="post">
|
212
|
+
<p>
|
213
|
+
<label for="html5_email">Html5 Email</label>
|
214
|
+
<input type="email" name="form[html5_email]" value="person@email.com" id="html5_email"/>
|
215
|
+
</p>
|
216
|
+
<p>
|
217
|
+
<label for="html5_url">Html5 Url</label>
|
218
|
+
<input type="url" name="form[html5_url]" value="http://www.example.com" id="html5_url"/>
|
219
|
+
</p>
|
220
|
+
<p>
|
221
|
+
<label for="html5_search">Html5 Search</label>
|
222
|
+
<input type="search" name="form[html5_search]" value="what are you looking for" id="html5_search"/>
|
223
|
+
</p>
|
224
|
+
<p>
|
225
|
+
<label for="html5_tel">Html5 Tel</label>
|
226
|
+
<input type="tel" name="form[html5_tel]" value="911" id="html5_tel"/>
|
227
|
+
</p>
|
228
|
+
<p>
|
229
|
+
<label for="html5_color">Html5 Color</label>
|
230
|
+
<input type="color" name="form[html5_color]" value="#FFF" id="html5_color"/>
|
231
|
+
</p>
|
232
|
+
|
233
|
+
<p>
|
234
|
+
<input type="submit" name="form[html5_submit]" value="html5_submit"/>
|
235
|
+
</p>
|
236
|
+
</form>
|
237
|
+
|
238
|
+
<form action="/form" method="post">
|
239
|
+
<p>
|
240
|
+
<button type="submit" name="form[button]" value="button_first">Just an input that came first</button>
|
241
|
+
<button type="submit" name="form[button]" value="button_second">Just an input</button>
|
242
|
+
<input type="submit" name="form[button]" value="Just a button that came first"/>
|
243
|
+
<input type="submit" name="form[button]" value="Just a button"/>
|
244
|
+
</p>
|
245
|
+
</form>
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<form action="/form" method="post">
|
2
|
+
<table id="agent_table">
|
3
|
+
<caption>Agent</caption>
|
4
|
+
|
5
|
+
<tr>
|
6
|
+
<td>
|
7
|
+
<label for="form_agent_name">Name</label>
|
8
|
+
</td>
|
9
|
+
<td>
|
10
|
+
<input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
|
11
|
+
</td>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<tr>
|
15
|
+
<td colspan="2">
|
16
|
+
<input type="submit" value="Create"/>
|
17
|
+
</td>
|
18
|
+
</tr>
|
19
|
+
</table>
|
20
|
+
</form>
|
21
|
+
|
22
|
+
<form action="/form" method="post">
|
23
|
+
<table id="girl_table">
|
24
|
+
<caption>Girl</caption>
|
25
|
+
|
26
|
+
<tr>
|
27
|
+
<td>
|
28
|
+
<label for="form_girl_name">Name</label>
|
29
|
+
</td>
|
30
|
+
<td>
|
31
|
+
<input type="text" name="form[girl_name]" value="Vesper" id="form_girl_name"/>
|
32
|
+
</td>
|
33
|
+
</tr>
|
34
|
+
|
35
|
+
<tr>
|
36
|
+
<td colspan="2">
|
37
|
+
<input type="submit" value="Create"/>
|
38
|
+
</td>
|
39
|
+
</tr>
|
40
|
+
</table>
|
41
|
+
</form>
|
42
|
+
|
43
|
+
<form action="/form" method="post">
|
44
|
+
<table id="villain_table">
|
45
|
+
<caption>Villain</caption>
|
46
|
+
|
47
|
+
<tr>
|
48
|
+
<td>
|
49
|
+
<label for="form_villain_name">Name</label>
|
50
|
+
</td>
|
51
|
+
<td>
|
52
|
+
<input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
|
53
|
+
</td>
|
54
|
+
</tr>
|
55
|
+
|
56
|
+
<tr>
|
57
|
+
<td colspan="2">
|
58
|
+
<input type="submit" value="Create"/>
|
59
|
+
</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
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>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<h1>This is a test</h1>
|
2
|
+
|
3
|
+
<p id="first">
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
5
|
+
tempor incididunt ut <a href="/with_simple_html" title="awesome title" class="simple">labore</a>
|
6
|
+
et dolore magna aliqua. Ut enim ad minim veniam,
|
7
|
+
quis nostrud exercitation <a href="/foo" id="foo">ullamco</a> laboris nisi
|
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>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p id="second">
|
13
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
|
14
|
+
dolore eu fugiat <a href="/redirect" id="red">Redirect</a> pariatur. Excepteur sint occaecat cupidatat non proident,
|
15
|
+
sunt in culpa qui officia
|
16
|
+
text with
|
17
|
+
whitespace
|
18
|
+
id est laborum.
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
<input type="text" id="test_field" value="monkey"/>
|
23
|
+
<textarea>banana</textarea>
|
24
|
+
<a href="/redirect_back">BackToMyself</a>
|
25
|
+
<a title="twas a fine link" href="/redirect">A link came first</a>
|
26
|
+
<a title="a fine link" href="/with_simple_html">A link</a>
|
27
|
+
<a title="a fine link with data method" data-method="delete" href="/delete">A link with data-method</a>
|
28
|
+
<a>No Href</a>
|
29
|
+
<a href="">Blank Href</a>
|
30
|
+
<a href="#">Blank Anchor</a>
|
31
|
+
<a href="#anchor">Anchor</a>
|
32
|
+
<a href="/with_simple_html#anchor">Anchor on different page</a>
|
33
|
+
<a href="/with_html#anchor">Anchor on same page</a>
|
34
|
+
<input type="text" value="" id="test_field">
|
35
|
+
<input type="text" checked="checked" id="checked_field">
|
36
|
+
<a href="/redirect"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="very fine image" /></a>
|
37
|
+
<a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="fine image" /></a>
|
38
|
+
</p>
|
39
|
+
|
40
|
+
<div id="hidden" style="display: none;">
|
41
|
+
<div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
|
42
|
+
<a href="/with_simple_html" title="awesome title" class="simple">hidden link</a>
|
43
|
+
</div>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
4
|
+
<title>with_js</title>
|
5
|
+
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
6
|
+
<script src="/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
|
7
|
+
<script src="/test.js" type="text/javascript" charset="utf-8"></script>
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body id="with_js">
|
11
|
+
<h1>FooBar</h1>
|
12
|
+
|
13
|
+
<p id="change">This is text</p>
|
14
|
+
<div id="drag">
|
15
|
+
<p>This is a draggable element.</p>
|
16
|
+
</div>
|
17
|
+
<div id="drop">
|
18
|
+
<p>It should be dropped here.</p>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<p><a href="#" id="clickable">Click me</a></p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<select id="waiter">
|
25
|
+
<option>Foo</option>
|
26
|
+
<option>My Waiting Option</option>
|
27
|
+
</select>
|
28
|
+
</p>
|
29
|
+
|
30
|
+
<p>
|
31
|
+
<input type="text" name="with_focus_event" value="" id="with_focus_event"/>
|
32
|
+
</p>
|
33
|
+
|
34
|
+
<p>
|
35
|
+
<input type="checkbox" id="checkbox_with_event"/>
|
36
|
+
</p>
|
37
|
+
</body>
|
38
|
+
</html>
|
39
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<h1>This page is used for testing various scopes</h1>
|
2
|
+
|
3
|
+
<p id="for_foo">
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
5
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim venia.
|
6
|
+
<a href="/redirect">Go</a>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<div id="for_bar">
|
10
|
+
<ul>
|
11
|
+
<li>With Simple HTML: <a href="/with_simple_html">Go</a>
|
12
|
+
<form action="/redirect" method="post" accept-charset="utf-8">
|
13
|
+
<p>
|
14
|
+
<label for="simple_first_name">First Name</label>
|
15
|
+
<input type="text" name="first_name" value="John" id="simple_first_name"/>
|
16
|
+
</p>
|
17
|
+
<p><input type="submit" value="Go"/></p>
|
18
|
+
</form>
|
19
|
+
</li>
|
20
|
+
<li>Bar: <a href="/foo">Go</a>
|
21
|
+
<form action="/form" method="post" accept-charset="utf-8">
|
22
|
+
<p>
|
23
|
+
<label for="bar_first_name">First Name</label>
|
24
|
+
<input type="text" name="form[first_name]" value="Peter" id="bar_first_name"/>
|
25
|
+
</p>
|
26
|
+
<p><input type="submit" value="Go"/></p>
|
27
|
+
</form>
|
28
|
+
</li>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div id="another_foo">
|
33
|
+
<ul>
|
34
|
+
<li>With Simple HTML: <a href="/">Go</a>
|
35
|
+
</ul>
|
36
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
Bar
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Capybara::Driver::Mechanize do
|
3
|
+
describe "Capybara::Driver::Mechanize, in local model" do
|
4
4
|
before do
|
5
5
|
@driver = Capybara::Driver::Mechanize.new(TestApp)
|
6
6
|
end
|
@@ -19,7 +19,6 @@ describe Capybara::Driver::Mechanize do
|
|
19
19
|
# Pending:
|
20
20
|
# it_should_behave_like "driver with infinite redirect detection"
|
21
21
|
|
22
|
-
|
23
22
|
it "should default to local mode" do
|
24
23
|
@driver.remote?('http://www.local.com').should be false
|
25
24
|
end
|
@@ -13,11 +13,13 @@ describe Capybara::Driver::Mechanize do
|
|
13
13
|
@driver = Capybara::Driver::Mechanize.new(TestApp)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
context "in remote mode" do
|
17
|
+
it_should_behave_like "driver"
|
18
|
+
it_should_behave_like "driver with header support"
|
19
|
+
it_should_behave_like "driver with status code support"
|
20
|
+
it_should_behave_like "driver with cookies support"
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
# Pending:
|
23
|
+
# it_should_behave_like "driver with infinite redirect detection"
|
24
|
+
end
|
23
25
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Capybara::Session do
|
4
|
+
context 'with remote mechanize driver' do
|
5
|
+
before(:each) do
|
6
|
+
Capybara.app_host = "http://capybara-testapp.heroku.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
Capybara.app_host = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
before do
|
15
|
+
@session = Capybara::Session.new(:mechanize, TestApp)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#driver' do
|
19
|
+
it "should be a mechanize driver" do
|
20
|
+
@session.driver.should be_an_instance_of(Capybara::Driver::Mechanize)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#mode' do
|
25
|
+
it "should remember the mode" do
|
26
|
+
@session.mode.should == :mechanize
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#click_link' do
|
31
|
+
it "should use data-method if available" do
|
32
|
+
pending "Needs to be implemented" do
|
33
|
+
@session.visit "/with_html"
|
34
|
+
@session.click_link "A link with data-method"
|
35
|
+
@session.body.should == 'The requested object was deleted'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Pending: Still 12 failing tests here:
|
41
|
+
# it_should_behave_like "session"
|
42
|
+
|
43
|
+
it_should_behave_like "session without javascript support"
|
44
|
+
it_should_behave_like "session with headers support"
|
45
|
+
it_should_behave_like "session with status code support"
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-mechanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeroen van Dijk
|
@@ -78,9 +78,23 @@ files:
|
|
78
78
|
- lib/capybara/driver/mechanize.rb
|
79
79
|
- lib/capybara/mechanize/cucumber.rb
|
80
80
|
- lib/capybara/mechanize.rb
|
81
|
+
- lib/capybara/spec/extended_test_app.rb
|
82
|
+
- lib/capybara/spec/views/buttons.erb
|
83
|
+
- lib/capybara/spec/views/fieldsets.erb
|
84
|
+
- lib/capybara/spec/views/form.erb
|
85
|
+
- lib/capybara/spec/views/frame_one.erb
|
86
|
+
- lib/capybara/spec/views/frame_two.erb
|
87
|
+
- lib/capybara/spec/views/postback.erb
|
88
|
+
- lib/capybara/spec/views/tables.erb
|
89
|
+
- lib/capybara/spec/views/with_html.erb
|
90
|
+
- lib/capybara/spec/views/with_js.erb
|
91
|
+
- lib/capybara/spec/views/with_scope.erb
|
92
|
+
- lib/capybara/spec/views/with_simple_html.erb
|
93
|
+
- lib/capybara/spec/views/within_frames.erb
|
81
94
|
- spec/driver/mechanize_driver_spec.rb
|
82
95
|
- spec/driver/remote_mechanize_driver_spec.rb
|
83
96
|
- spec/session/mechanize_spec.rb
|
97
|
+
- spec/session/remote_mechanize_spec.rb
|
84
98
|
- spec/spec.opts
|
85
99
|
- spec/spec_helper.rb
|
86
100
|
- README.mdown
|