mechanize 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- data/EXAMPLES.txt +87 -40
- data/History.txt +21 -0
- data/Manifest.txt +51 -47
- data/lib/www/mechanize.rb +88 -22
- data/lib/www/mechanize/cookie.rb +1 -1
- data/lib/www/mechanize/form.rb +27 -14
- data/lib/www/mechanize/form/multi_select_list.rb +1 -1
- data/lib/www/mechanize/monkey_patch.rb +3 -0
- data/lib/www/mechanize/page.rb +20 -16
- data/lib/www/mechanize/page/link.rb +2 -2
- data/lib/www/mechanize/redirect_limit_reached_error.rb +18 -0
- data/test/helper.rb +14 -0
- data/test/htdocs/meta_cookie.html +11 -0
- data/test/servlets.rb +10 -0
- data/test/{tc_authenticate.rb → test_authenticate.rb} +0 -0
- data/test/{tc_bad_links.rb → test_bad_links.rb} +0 -0
- data/test/{tc_blank_form.rb → test_blank_form.rb} +0 -0
- data/test/{tc_checkboxes.rb → test_checkboxes.rb} +0 -0
- data/test/{tc_cookie_class.rb → test_cookie_class.rb} +9 -0
- data/test/{tc_cookie_jar.rb → test_cookie_jar.rb} +0 -0
- data/test/{tc_cookies.rb → test_cookies.rb} +6 -0
- data/test/{tc_encoded_links.rb → test_encoded_links.rb} +1 -1
- data/test/{tc_errors.rb → test_errors.rb} +0 -0
- data/test/{tc_follow_meta.rb → test_follow_meta.rb} +0 -0
- data/test/{tc_form_action.rb → test_form_action.rb} +1 -1
- data/test/{tc_form_as_hash.rb → test_form_as_hash.rb} +0 -0
- data/test/{tc_form_button.rb → test_form_button.rb} +0 -0
- data/test/{tc_form_no_inputname.rb → test_form_no_inputname.rb} +0 -0
- data/test/{tc_forms.rb → test_forms.rb} +0 -0
- data/test/{tc_frames.rb → test_frames.rb} +0 -0
- data/test/test_get_headers.rb +45 -0
- data/test/{tc_gzipping.rb → test_gzipping.rb} +0 -0
- data/test/test_hash_api.rb +42 -0
- data/test/{tc_history.rb → test_history.rb} +0 -0
- data/test/{tc_history_added.rb → test_history_added.rb} +0 -0
- data/test/{tc_html_unscape_forms.rb → test_html_unscape_forms.rb} +0 -0
- data/test/{tc_if_modified_since.rb → test_if_modified_since.rb} +0 -0
- data/test/{tc_keep_alive.rb → test_keep_alive.rb} +0 -0
- data/test/{tc_links.rb → test_links.rb} +0 -0
- data/test/{tc_mech.rb → test_mech.rb} +2 -2
- data/test/{tc_mechanize_file.rb → test_mechanize_file.rb} +0 -0
- data/test/{tc_multi_select.rb → test_multi_select.rb} +0 -0
- data/test/{tc_no_attributes.rb → test_no_attributes.rb} +0 -0
- data/test/{tc_option.rb → test_option.rb} +0 -0
- data/test/{tc_page.rb → test_page.rb} +17 -0
- data/test/{tc_pluggable_parser.rb → test_pluggable_parser.rb} +0 -0
- data/test/{tc_post_form.rb → test_post_form.rb} +0 -0
- data/test/{tc_pretty_print.rb → test_pretty_print.rb} +0 -0
- data/test/{tc_radiobutton.rb → test_radiobutton.rb} +0 -0
- data/test/test_redirect_limit_reached.rb +41 -0
- data/test/{tc_referer.rb → test_referer.rb} +0 -0
- data/test/{tc_relative_links.rb → test_relative_links.rb} +0 -0
- data/test/{tc_response_code.rb → test_response_code.rb} +0 -0
- data/test/{tc_save_file.rb → test_save_file.rb} +0 -0
- data/test/{tc_select.rb → test_select.rb} +0 -0
- data/test/{tc_select_all.rb → test_select_all.rb} +0 -0
- data/test/{tc_select_none.rb → test_select_none.rb} +0 -0
- data/test/{tc_select_noopts.rb → test_select_noopts.rb} +0 -0
- data/test/{tc_set_fields.rb → test_set_fields.rb} +8 -0
- data/test/{tc_ssl_server.rb → test_ssl_server.rb} +0 -0
- data/test/{tc_subclass.rb → test_subclass.rb} +0 -0
- data/test/{tc_textarea.rb → test_textarea.rb} +0 -0
- data/test/{tc_upload.rb → test_upload.rb} +11 -11
- metadata +106 -52
- data/test/test_all.rb +0 -5
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -172,7 +172,7 @@ class TestMechMethods < Test::Unit::TestCase
|
|
172
172
|
def test_click_hpricot
|
173
173
|
page = @agent.get("http://localhost/frame_test.html")
|
174
174
|
|
175
|
-
link = (page/"a[@class=bar]").first
|
175
|
+
link = (page/"//a[@class='bar']").first
|
176
176
|
assert_not_nil(link)
|
177
177
|
page = @agent.click(link)
|
178
178
|
assert_equal("http://localhost/form_test.html",
|
@@ -182,7 +182,7 @@ class TestMechMethods < Test::Unit::TestCase
|
|
182
182
|
def test_click_hpricot_frame
|
183
183
|
page = @agent.get("http://localhost/frame_test.html")
|
184
184
|
|
185
|
-
link = (page/"frame[@name=frame2]").first
|
185
|
+
link = (page/"//frame[@name='frame2']").first
|
186
186
|
assert_not_nil(link)
|
187
187
|
page = @agent.click(link)
|
188
188
|
assert_equal("http://localhost/form_test.html",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -23,4 +23,21 @@ class TestPage < Test::Unit::TestCase
|
|
23
23
|
page = @agent.get("http://localhost/no_title_test.html")
|
24
24
|
assert_equal(nil, page.title)
|
25
25
|
end
|
26
|
+
|
27
|
+
def test_find_form_with_hash
|
28
|
+
page = @agent.get("http://localhost/tc_form_action.html")
|
29
|
+
form = page.form(:name => 'post_form1')
|
30
|
+
assert form
|
31
|
+
yielded = false
|
32
|
+
form = page.form(:name => 'post_form1') { |f|
|
33
|
+
yielded = true
|
34
|
+
assert f
|
35
|
+
assert_equal(form, f)
|
36
|
+
}
|
37
|
+
assert yielded
|
38
|
+
|
39
|
+
form_by_action = page.form(:action => '/form_post?a=b&b=c')
|
40
|
+
assert form_by_action
|
41
|
+
assert_equal(form, form_by_action)
|
42
|
+
end
|
26
43
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class TestRedirectLimitReached < Test::Unit::TestCase
|
4
|
+
include WWW
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@agent = WWW::Mechanize.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_to_s
|
11
|
+
page = MechTestHelper.fake_page(@agent)
|
12
|
+
error = Mechanize::RedirectLimitReachedError.new(page, 10)
|
13
|
+
assert_match(/10/, error.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_get_default_redirects
|
17
|
+
assert_raises(Mechanize::RedirectLimitReachedError) {
|
18
|
+
begin
|
19
|
+
@agent.get('http://localhost/infinite_redirect')
|
20
|
+
rescue Mechanize::RedirectLimitReachedError => ex
|
21
|
+
assert_equal(@agent.redirection_limit, ex.redirects)
|
22
|
+
assert_equal("q=#{@agent.redirection_limit}", ex.page.uri.query)
|
23
|
+
raise ex
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_2_redirects
|
29
|
+
@agent.redirection_limit = 2
|
30
|
+
assert_raises(Mechanize::RedirectLimitReachedError) {
|
31
|
+
begin
|
32
|
+
@agent.get('http://localhost/infinite_redirect')
|
33
|
+
rescue Mechanize::RedirectLimitReachedError => ex
|
34
|
+
assert_equal(2, ex.redirects)
|
35
|
+
assert_equal(@agent.redirection_limit, ex.redirects)
|
36
|
+
assert_equal("q=#{@agent.redirection_limit}", ex.page.uri.query)
|
37
|
+
raise ex
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -29,6 +29,14 @@ class TestSetFields < Test::Unit::TestCase
|
|
29
29
|
assert_equal('Ham', @form.fields.name('green[eggs]').first.value)
|
30
30
|
end
|
31
31
|
|
32
|
+
def test_set_multiple_duplicate_fields
|
33
|
+
page = @agent.get("http://localhost/form_multival.html")
|
34
|
+
form = page.form('post_form')
|
35
|
+
form.set_fields( :first => { 0 => 'a', 1 => 'b' } )
|
36
|
+
assert_equal('a', form.fields.name('first')[0].value)
|
37
|
+
assert_equal('b', form.fields.name('first')[1].value)
|
38
|
+
end
|
39
|
+
|
32
40
|
def test_set_second_field
|
33
41
|
@form.set_fields( :first_name => ['Aaron', 1] )
|
34
42
|
assert_equal('Aaron', @form.fields.name('first_name')[1].value)
|
File without changes
|
File without changes
|
File without changes
|
@@ -22,14 +22,14 @@ class UploadMechTest < Test::Unit::TestCase
|
|
22
22
|
assert_equal('multipart/form-data', @page.forms[0].enctype)
|
23
23
|
|
24
24
|
form = @page.forms.first
|
25
|
-
form.file_uploads.first.file_name = "#{BASE_DIR}/
|
25
|
+
form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
|
26
26
|
form.file_uploads.first.mime_type = "text/plain"
|
27
27
|
form.file_uploads.first.file_data = "Hello World\n\n"
|
28
28
|
|
29
29
|
@page = @agent.submit(form)
|
30
30
|
|
31
31
|
assert_match(
|
32
|
-
"Content-Disposition: form-data; name=\"userfile1\"; filename=\"
|
32
|
+
"Content-Disposition: form-data; name=\"userfile1\"; filename=\"helper.rb\"",
|
33
33
|
@page.body
|
34
34
|
)
|
35
35
|
assert_match(
|
@@ -45,14 +45,14 @@ class UploadMechTest < Test::Unit::TestCase
|
|
45
45
|
assert_equal('multipart/form-data', @page.forms[1].enctype)
|
46
46
|
|
47
47
|
form = @page.forms[1]
|
48
|
-
form.file_uploads.first.file_name = "#{BASE_DIR}/
|
48
|
+
form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
|
49
49
|
form.file_uploads.first.mime_type = "text/plain"
|
50
50
|
form.file_uploads.first.file_data = "Hello World\n\n"
|
51
51
|
|
52
52
|
@page = @agent.submit(form)
|
53
53
|
|
54
54
|
assert_match(
|
55
|
-
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"
|
55
|
+
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
|
56
56
|
@page.body
|
57
57
|
)
|
58
58
|
end
|
@@ -61,13 +61,13 @@ class UploadMechTest < Test::Unit::TestCase
|
|
61
61
|
assert_equal('multipart/form-data', @page.forms[1].enctype)
|
62
62
|
|
63
63
|
form = @page.forms[1]
|
64
|
-
form.file_uploads.first.file_name = "#{BASE_DIR}/
|
64
|
+
form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
|
65
65
|
|
66
66
|
@page = @agent.submit(form)
|
67
67
|
|
68
|
-
contents = File.open("#{BASE_DIR}/
|
68
|
+
contents = File.open("#{BASE_DIR}/helper.rb", 'rb') { |f| f.read }
|
69
69
|
assert_match(
|
70
|
-
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"
|
70
|
+
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
|
71
71
|
@page.body
|
72
72
|
)
|
73
73
|
assert_match(contents, @page.body)
|
@@ -77,14 +77,14 @@ class UploadMechTest < Test::Unit::TestCase
|
|
77
77
|
assert_equal('multipart/form-data', @page.forms[1].enctype)
|
78
78
|
|
79
79
|
form = @page.forms[1]
|
80
|
-
form.file_uploads.first.file_name = "#{BASE_DIR}/
|
81
|
-
form.file_uploads.first.file_data = File.open("#{BASE_DIR}/
|
80
|
+
form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
|
81
|
+
form.file_uploads.first.file_data = File.open("#{BASE_DIR}/helper.rb", 'rb')
|
82
82
|
|
83
83
|
@page = @agent.submit(form)
|
84
84
|
|
85
|
-
contents = File.open("#{BASE_DIR}/
|
85
|
+
contents = File.open("#{BASE_DIR}/helper.rb", 'rb') { |f| f.read }
|
86
86
|
assert_match(
|
87
|
-
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"
|
87
|
+
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
|
88
88
|
@page.body
|
89
89
|
)
|
90
90
|
assert_match(contents, @page.body)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mechanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-07-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hpricot
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -23,12 +24,13 @@ dependencies:
|
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: hoe
|
27
|
+
type: :development
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
29
31
|
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
31
|
-
version: 1.
|
33
|
+
version: 1.7.0
|
32
34
|
version:
|
33
35
|
description: The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.
|
34
36
|
email: aaronp@rubyforge.org
|
@@ -88,6 +90,7 @@ files:
|
|
88
90
|
- lib/www/mechanize/page/link.rb
|
89
91
|
- lib/www/mechanize/page/meta.rb
|
90
92
|
- lib/www/mechanize/pluggable_parsers.rb
|
93
|
+
- lib/www/mechanize/redirect_limit_reached_error.rb
|
91
94
|
- lib/www/mechanize/response_code_error.rb
|
92
95
|
- lib/www/mechanize/unsupported_scheme_error.rb
|
93
96
|
- test/data/htpasswd
|
@@ -117,6 +120,7 @@ files:
|
|
117
120
|
- test/htdocs/iframe_test.html
|
118
121
|
- test/htdocs/index.html
|
119
122
|
- test/htdocs/link with space.html
|
123
|
+
- test/htdocs/meta_cookie.html
|
120
124
|
- test/htdocs/no_title_test.html
|
121
125
|
- test/htdocs/relative/tc_relative_links.html
|
122
126
|
- test/htdocs/tc_bad_links.html
|
@@ -136,53 +140,55 @@ files:
|
|
136
140
|
- test/htdocs/unusual______.html
|
137
141
|
- test/servlets.rb
|
138
142
|
- test/ssl_server.rb
|
139
|
-
- test/
|
140
|
-
- test/
|
141
|
-
- test/
|
142
|
-
- test/
|
143
|
-
- test/
|
144
|
-
- test/
|
145
|
-
- test/
|
146
|
-
- test/
|
147
|
-
- test/
|
148
|
-
- test/
|
149
|
-
- test/
|
150
|
-
- test/
|
151
|
-
- test/
|
152
|
-
- test/
|
153
|
-
- test/
|
154
|
-
- test/
|
155
|
-
- test/
|
156
|
-
- test/
|
157
|
-
- test/
|
158
|
-
- test/
|
159
|
-
- test/
|
160
|
-
- test/
|
161
|
-
- test/
|
162
|
-
- test/
|
163
|
-
- test/
|
164
|
-
- test/
|
165
|
-
- test/
|
166
|
-
- test/
|
167
|
-
- test/
|
168
|
-
- test/
|
169
|
-
- test/
|
170
|
-
- test/
|
171
|
-
- test/
|
172
|
-
- test/
|
173
|
-
- test/
|
174
|
-
- test/
|
175
|
-
- test/
|
176
|
-
- test/
|
177
|
-
- test/
|
178
|
-
- test/
|
179
|
-
- test/
|
180
|
-
- test/
|
181
|
-
- test/
|
182
|
-
- test/
|
183
|
-
- test/
|
184
|
-
- test/
|
185
|
-
- test/
|
143
|
+
- test/test_authenticate.rb
|
144
|
+
- test/test_bad_links.rb
|
145
|
+
- test/test_blank_form.rb
|
146
|
+
- test/test_checkboxes.rb
|
147
|
+
- test/test_cookie_class.rb
|
148
|
+
- test/test_cookie_jar.rb
|
149
|
+
- test/test_cookies.rb
|
150
|
+
- test/test_encoded_links.rb
|
151
|
+
- test/test_errors.rb
|
152
|
+
- test/test_follow_meta.rb
|
153
|
+
- test/test_form_action.rb
|
154
|
+
- test/test_form_as_hash.rb
|
155
|
+
- test/test_form_button.rb
|
156
|
+
- test/test_form_no_inputname.rb
|
157
|
+
- test/test_forms.rb
|
158
|
+
- test/test_frames.rb
|
159
|
+
- test/test_get_headers.rb
|
160
|
+
- test/test_gzipping.rb
|
161
|
+
- test/test_hash_api.rb
|
162
|
+
- test/test_history.rb
|
163
|
+
- test/test_history_added.rb
|
164
|
+
- test/test_html_unscape_forms.rb
|
165
|
+
- test/test_if_modified_since.rb
|
166
|
+
- test/test_keep_alive.rb
|
167
|
+
- test/test_links.rb
|
168
|
+
- test/test_mech.rb
|
169
|
+
- test/test_mechanize_file.rb
|
170
|
+
- test/test_multi_select.rb
|
171
|
+
- test/test_no_attributes.rb
|
172
|
+
- test/test_option.rb
|
173
|
+
- test/test_page.rb
|
174
|
+
- test/test_pluggable_parser.rb
|
175
|
+
- test/test_post_form.rb
|
176
|
+
- test/test_pretty_print.rb
|
177
|
+
- test/test_radiobutton.rb
|
178
|
+
- test/test_redirect_limit_reached.rb
|
179
|
+
- test/test_referer.rb
|
180
|
+
- test/test_relative_links.rb
|
181
|
+
- test/test_response_code.rb
|
182
|
+
- test/test_save_file.rb
|
183
|
+
- test/test_select.rb
|
184
|
+
- test/test_select_all.rb
|
185
|
+
- test/test_select_none.rb
|
186
|
+
- test/test_select_noopts.rb
|
187
|
+
- test/test_set_fields.rb
|
188
|
+
- test/test_ssl_server.rb
|
189
|
+
- test/test_subclass.rb
|
190
|
+
- test/test_textarea.rb
|
191
|
+
- test/test_upload.rb
|
186
192
|
has_rdoc: true
|
187
193
|
homepage: " http://mechanize.rubyforge.org/"
|
188
194
|
post_install_message:
|
@@ -206,9 +212,57 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
212
|
requirements: []
|
207
213
|
|
208
214
|
rubyforge_project: mechanize
|
209
|
-
rubygems_version: 1.
|
215
|
+
rubygems_version: 1.2.0
|
210
216
|
signing_key:
|
211
217
|
specification_version: 2
|
212
218
|
summary: Mechanize provides automated web-browsing
|
213
219
|
test_files:
|
214
|
-
- test/
|
220
|
+
- test/test_authenticate.rb
|
221
|
+
- test/test_bad_links.rb
|
222
|
+
- test/test_blank_form.rb
|
223
|
+
- test/test_checkboxes.rb
|
224
|
+
- test/test_cookie_class.rb
|
225
|
+
- test/test_cookie_jar.rb
|
226
|
+
- test/test_cookies.rb
|
227
|
+
- test/test_encoded_links.rb
|
228
|
+
- test/test_errors.rb
|
229
|
+
- test/test_follow_meta.rb
|
230
|
+
- test/test_form_action.rb
|
231
|
+
- test/test_form_as_hash.rb
|
232
|
+
- test/test_form_button.rb
|
233
|
+
- test/test_form_no_inputname.rb
|
234
|
+
- test/test_forms.rb
|
235
|
+
- test/test_frames.rb
|
236
|
+
- test/test_get_headers.rb
|
237
|
+
- test/test_gzipping.rb
|
238
|
+
- test/test_hash_api.rb
|
239
|
+
- test/test_history.rb
|
240
|
+
- test/test_history_added.rb
|
241
|
+
- test/test_html_unscape_forms.rb
|
242
|
+
- test/test_if_modified_since.rb
|
243
|
+
- test/test_keep_alive.rb
|
244
|
+
- test/test_links.rb
|
245
|
+
- test/test_mech.rb
|
246
|
+
- test/test_mechanize_file.rb
|
247
|
+
- test/test_multi_select.rb
|
248
|
+
- test/test_no_attributes.rb
|
249
|
+
- test/test_option.rb
|
250
|
+
- test/test_page.rb
|
251
|
+
- test/test_pluggable_parser.rb
|
252
|
+
- test/test_post_form.rb
|
253
|
+
- test/test_pretty_print.rb
|
254
|
+
- test/test_radiobutton.rb
|
255
|
+
- test/test_redirect_limit_reached.rb
|
256
|
+
- test/test_referer.rb
|
257
|
+
- test/test_relative_links.rb
|
258
|
+
- test/test_response_code.rb
|
259
|
+
- test/test_save_file.rb
|
260
|
+
- test/test_select.rb
|
261
|
+
- test/test_select_all.rb
|
262
|
+
- test/test_select_none.rb
|
263
|
+
- test/test_select_noopts.rb
|
264
|
+
- test/test_set_fields.rb
|
265
|
+
- test/test_ssl_server.rb
|
266
|
+
- test/test_subclass.rb
|
267
|
+
- test/test_textarea.rb
|
268
|
+
- test/test_upload.rb
|