mechanize 0.9.1 → 0.9.2
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/{History.txt → CHANGELOG.rdoc} +14 -1
- data/{EXAMPLES.txt → EXAMPLES.rdoc} +0 -0
- data/{FAQ.txt → FAQ.rdoc} +0 -0
- data/{GUIDE.txt → GUIDE.rdoc} +0 -0
- data/{LICENSE.txt → LICENSE.rdoc} +0 -0
- data/Manifest.txt +6 -6
- data/{README.txt → README.rdoc} +15 -6
- data/Rakefile +3 -0
- data/lib/www/mechanize.rb +6 -5
- data/lib/www/mechanize/chain/response_header_handler.rb +3 -2
- data/lib/www/mechanize/cookie.rb +2 -0
- data/lib/www/mechanize/form.rb +3 -3
- data/lib/www/mechanize/form/radio_button.rb +1 -1
- data/lib/www/mechanize/page.rb +9 -3
- data/lib/www/mechanize/util.rb +3 -1
- data/mechanize.gemspec +12 -12
- data/test/test_cookie_class.rb +9 -0
- data/test/test_forms.rb +29 -0
- data/test/test_mech.rb +11 -0
- data/test/test_page.rb +18 -0
- data/test/test_radiobutton.rb +12 -0
- metadata +15 -15
@@ -1,6 +1,19 @@
|
|
1
1
|
= Mechanize CHANGELOG
|
2
2
|
|
3
|
-
===
|
3
|
+
=== 0.9.2 / 2009/03/05
|
4
|
+
|
5
|
+
* New Features:
|
6
|
+
* Mechanize#submit and Form#submit take arbitrary headers(thanks penguincoder)
|
7
|
+
|
8
|
+
* Bug Fixes:
|
9
|
+
* Fixed a bug with bad cookie parsing
|
10
|
+
* Form::RadioButton#click unchecks other buttons (RF #24159)
|
11
|
+
* Fixed problems with Iconv (RF #24190, RF #24192, RF #24043)
|
12
|
+
* POST parameters should be CGI escaped
|
13
|
+
* Made Content-Type match case insensitive (Thanks Kelly Reynolds)
|
14
|
+
* Non-string form parameters work
|
15
|
+
|
16
|
+
=== 0.9.1 2009/02/23
|
4
17
|
|
5
18
|
* New Features:
|
6
19
|
* Encoding may be specified for a page: Page#encoding=
|
File without changes
|
data/{FAQ.txt → FAQ.rdoc}
RENAMED
File without changes
|
data/{GUIDE.txt → GUIDE.rdoc}
RENAMED
File without changes
|
File without changes
|
data/Manifest.txt
CHANGED
data/{README.txt → README.rdoc}
RENAMED
@@ -13,20 +13,29 @@ a history.
|
|
13
13
|
|
14
14
|
== Dependencies
|
15
15
|
|
16
|
-
* ruby 1.8.
|
17
|
-
*
|
16
|
+
* ruby 1.8.6
|
17
|
+
* nokogiri[http://nokogiri.rubyforge.org]
|
18
18
|
|
19
|
+
== SUPPORT:
|
20
|
+
|
21
|
+
The mechanize mailing list is available here:
|
22
|
+
|
23
|
+
* http://rubyforge.org/mailman/listinfo/mechanize-users
|
24
|
+
|
25
|
+
The bug tracker is available here:
|
26
|
+
|
27
|
+
* http://rubyforge.org/tracker/?atid=5709&group_id=1453
|
19
28
|
|
20
29
|
== Examples
|
21
30
|
|
22
|
-
If you are just starting, check out the GUIDE[link://files/
|
23
|
-
Also, check out the EXAMPLES[link://files/
|
31
|
+
If you are just starting, check out the GUIDE[link://files/GUIDE_rdoc.html].
|
32
|
+
Also, check out the EXAMPLES[link://files/EXAMPLES_rdoc.html] file.
|
24
33
|
|
25
34
|
== Authors
|
26
35
|
|
27
36
|
Copyright (c) 2005 by Michael Neumann (mneumann@ntecs.de)
|
28
37
|
|
29
|
-
Copyright (c) 2006-
|
38
|
+
Copyright (c) 2006-2009:
|
30
39
|
|
31
40
|
* {Aaron Patterson}[http://tenderlovemaking.com] (aaronp@rubyforge.org)
|
32
41
|
* {Mike Dalessio}[http://mike.daless.io] (mike@csa.net)
|
@@ -47,5 +56,5 @@ library!
|
|
47
56
|
|
48
57
|
== License
|
49
58
|
|
50
|
-
This library is distributed under the GPL. Please see the LICENSE[link://files/
|
59
|
+
This library is distributed under the GPL. Please see the LICENSE[link://files/LICENSE_rdoc.html] file.
|
51
60
|
|
data/Rakefile
CHANGED
@@ -8,6 +8,9 @@ HOE = Hoe.new('mechanize', WWW::Mechanize::VERSION) do |p|
|
|
8
8
|
p.rubyforge_name = 'mechanize'
|
9
9
|
p.developer('Aaron Patterson','aaronp@rubyforge.org')
|
10
10
|
p.developer('Mike Dalessio','mike.dalessio@gmail.com')
|
11
|
+
p.readme_file = 'README.rdoc'
|
12
|
+
p.history_file = 'CHANGELOG.rdoc'
|
13
|
+
p.extra_rdoc_files = FileList['*.rdoc']
|
11
14
|
p.summary = "Mechanize provides automated web-browsing"
|
12
15
|
p.extra_deps = [['nokogiri', '>= 1.2.1']]
|
13
16
|
end
|
data/lib/www/mechanize.rb
CHANGED
@@ -48,7 +48,7 @@ module WWW
|
|
48
48
|
class Mechanize
|
49
49
|
##
|
50
50
|
# The version of Mechanize you are using.
|
51
|
-
VERSION = '0.9.
|
51
|
+
VERSION = '0.9.2'
|
52
52
|
|
53
53
|
##
|
54
54
|
# User Agent aliases
|
@@ -328,14 +328,15 @@ module WWW
|
|
328
328
|
# agent.submit(page.forms.first)
|
329
329
|
# With a button
|
330
330
|
# agent.submit(page.forms.first, page.forms.first.buttons.first)
|
331
|
-
def submit(form, button=nil)
|
331
|
+
def submit(form, button=nil, headers={})
|
332
332
|
form.add_button_to_query(button) if button
|
333
333
|
case form.method.upcase
|
334
334
|
when 'POST'
|
335
|
-
post_form(form.action, form)
|
335
|
+
post_form(form.action, form, headers)
|
336
336
|
when 'GET'
|
337
337
|
get( :url => form.action.gsub(/\?[^\?]*$/, ''),
|
338
338
|
:params => form.build_query,
|
339
|
+
:headers => headers,
|
339
340
|
:referer => form.page
|
340
341
|
)
|
341
342
|
else
|
@@ -384,7 +385,7 @@ module WWW
|
|
384
385
|
hash[:uri].to_s
|
385
386
|
end
|
386
387
|
|
387
|
-
def post_form(url, form)
|
388
|
+
def post_form(url, form, headers = {})
|
388
389
|
cur_page = form.page || current_page ||
|
389
390
|
Page.new( nil, {'content-type'=>'text/html'})
|
390
391
|
|
@@ -400,7 +401,7 @@ module WWW
|
|
400
401
|
:headers => {
|
401
402
|
'Content-Type' => form.enctype,
|
402
403
|
'Content-Length' => request_data.size.to_s,
|
403
|
-
})
|
404
|
+
}.merge(headers))
|
404
405
|
add_to_history(page)
|
405
406
|
page
|
406
407
|
end
|
@@ -26,8 +26,9 @@ module WWW
|
|
26
26
|
cache_obj[:keep_alive_options][k.intern] = v
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
|
29
|
+
|
30
|
+
|
31
|
+
if page.is_a?(Page) && page.body =~ /Set-Cookie/n
|
31
32
|
page.search('//meta[@http-equiv="Set-Cookie"]').each do |meta|
|
32
33
|
Cookie::parse(uri, meta['content']) { |c|
|
33
34
|
Mechanize.log.debug("saved cookie: #{c}") if Mechanize.log
|
data/lib/www/mechanize/cookie.rb
CHANGED
@@ -12,11 +12,13 @@ module WWW
|
|
12
12
|
first_elem.strip!
|
13
13
|
key, value = first_elem.split(/=/, 2)
|
14
14
|
|
15
|
+
cookie = nil
|
15
16
|
begin
|
16
17
|
cookie = new(key, WEBrick::HTTPUtils.dequote(value))
|
17
18
|
rescue
|
18
19
|
log.warn("Couldn't parse key/value: #{first_elem}") if log
|
19
20
|
end
|
21
|
+
next unless cookie
|
20
22
|
|
21
23
|
cookie_elem.each{|pair|
|
22
24
|
pair.strip!
|
data/lib/www/mechanize/form.rb
CHANGED
@@ -126,8 +126,8 @@ module WWW
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Submit this form with the button passed in
|
129
|
-
def submit
|
130
|
-
@mech.submit(self, button)
|
129
|
+
def submit button=nil, headers = {}
|
130
|
+
@mech.submit(self, button, headers)
|
131
131
|
end
|
132
132
|
|
133
133
|
# Submit form using +button+. Defaults
|
@@ -140,7 +140,7 @@ module WWW
|
|
140
140
|
# It converts charset of query value of fields into excepted one.
|
141
141
|
def proc_query(field)
|
142
142
|
field.query_value.map{|(name, val)|
|
143
|
-
[from_native_charset(name), from_native_charset(val)]
|
143
|
+
[from_native_charset(name), from_native_charset(val.to_s)]
|
144
144
|
}
|
145
145
|
end
|
146
146
|
private :proc_query
|
data/lib/www/mechanize/page.rb
CHANGED
@@ -24,13 +24,19 @@ module WWW
|
|
24
24
|
attr_accessor :encoding
|
25
25
|
|
26
26
|
def initialize(uri=nil, response=nil, body=nil, code=nil, mech=nil)
|
27
|
+
@encoding = nil
|
28
|
+
response.each do |header,v|
|
29
|
+
next unless v =~ /charset/i
|
30
|
+
@encoding = v.split('=').last.strip
|
31
|
+
end
|
32
|
+
@encoding ||= Util.detect_charset(body)
|
33
|
+
body = Util.to_native_charset(body, @encoding) rescue body
|
34
|
+
|
27
35
|
super(uri, response, body, code)
|
28
|
-
@encoding = Util.detect_charset(body)
|
29
36
|
@mech ||= mech
|
30
37
|
|
31
38
|
raise Mechanize::ContentTypeError.new(response['content-type']) unless
|
32
|
-
|
33
|
-
|
39
|
+
response['content-type'] =~ /^(text\/html)|(application\/xhtml\+xml)/i
|
34
40
|
@parser = @links = @forms = @meta = @bases = @frames = @iframes = nil
|
35
41
|
end
|
36
42
|
|
data/lib/www/mechanize/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module WWW
|
2
4
|
class Mechanize
|
3
5
|
class Util
|
@@ -12,7 +14,7 @@ module WWW
|
|
12
14
|
parameters.map { |k,v|
|
13
15
|
if k
|
14
16
|
# WEBrick::HTTP.escape* has some problems about m17n on ruby-1.9.*.
|
15
|
-
[
|
17
|
+
[CGI.escape(k.to_s), CGI.escape(v.to_s)].join("=")
|
16
18
|
=begin
|
17
19
|
[WEBrick::HTTPUtils.escape_form(k.to_s),
|
18
20
|
WEBrick::HTTPUtils.escape_form(v.to_s)].join("=")
|
data/mechanize.gemspec
CHANGED
@@ -2,37 +2,37 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{mechanize}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.9.1.20090304135355"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Aaron Patterson", "Mike Dalessio"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2009-03-04}
|
10
10
|
s.description = %q{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.}
|
11
11
|
s.email = ["aaronp@rubyforge.org", "mike.dalessio@gmail.com"]
|
12
|
-
s.extra_rdoc_files = ["
|
13
|
-
s.files = ["
|
12
|
+
s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "EXAMPLES.rdoc", "FAQ.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "README.rdoc"]
|
13
|
+
s.files = ["CHANGELOG.rdoc", "EXAMPLES.rdoc", "FAQ.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "examples/flickr_upload.rb", "examples/mech-dump.rb", "examples/proxy_req.rb", "examples/rubyforge.rb", "examples/spider.rb", "lib/mechanize.rb", "lib/www/mechanize.rb", "lib/www/mechanize/chain.rb", "lib/www/mechanize/chain/auth_headers.rb", "lib/www/mechanize/chain/body_decoding_handler.rb", "lib/www/mechanize/chain/connection_resolver.rb", "lib/www/mechanize/chain/custom_headers.rb", "lib/www/mechanize/chain/handler.rb", "lib/www/mechanize/chain/header_resolver.rb", "lib/www/mechanize/chain/parameter_resolver.rb", "lib/www/mechanize/chain/post_connect_hook.rb", "lib/www/mechanize/chain/pre_connect_hook.rb", "lib/www/mechanize/chain/request_resolver.rb", "lib/www/mechanize/chain/response_body_parser.rb", "lib/www/mechanize/chain/response_header_handler.rb", "lib/www/mechanize/chain/response_reader.rb", "lib/www/mechanize/chain/ssl_resolver.rb", "lib/www/mechanize/chain/uri_resolver.rb", "lib/www/mechanize/content_type_error.rb", "lib/www/mechanize/cookie.rb", "lib/www/mechanize/cookie_jar.rb", "lib/www/mechanize/file.rb", "lib/www/mechanize/file_response.rb", "lib/www/mechanize/file_saver.rb", "lib/www/mechanize/form.rb", "lib/www/mechanize/form/button.rb", "lib/www/mechanize/form/check_box.rb", "lib/www/mechanize/form/field.rb", "lib/www/mechanize/form/file_upload.rb", "lib/www/mechanize/form/image_button.rb", "lib/www/mechanize/form/multi_select_list.rb", "lib/www/mechanize/form/option.rb", "lib/www/mechanize/form/radio_button.rb", "lib/www/mechanize/form/select_list.rb", "lib/www/mechanize/headers.rb", "lib/www/mechanize/history.rb", "lib/www/mechanize/inspect.rb", "lib/www/mechanize/monkey_patch.rb", "lib/www/mechanize/page.rb", "lib/www/mechanize/page/base.rb", "lib/www/mechanize/page/frame.rb", "lib/www/mechanize/page/link.rb", "lib/www/mechanize/page/meta.rb", "lib/www/mechanize/pluggable_parsers.rb", "lib/www/mechanize/redirect_limit_reached_error.rb", "lib/www/mechanize/redirect_not_get_or_head_error.rb", "lib/www/mechanize/response_code_error.rb", "lib/www/mechanize/unsupported_scheme_error.rb", "lib/www/mechanize/util.rb", "mechanize.gemspec", "test/chain/test_argument_validator.rb", "test/chain/test_custom_headers.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/data/htpasswd", "test/data/server.crt", "test/data/server.csr", "test/data/server.key", "test/data/server.pem", "test/helper.rb", "test/htdocs/alt_text.html", "test/htdocs/bad_form_test.html", "test/htdocs/button.jpg", "test/htdocs/empty_form.html", "test/htdocs/file_upload.html", "test/htdocs/find_link.html", "test/htdocs/form_multi_select.html", "test/htdocs/form_multival.html", "test/htdocs/form_no_action.html", "test/htdocs/form_no_input_name.html", "test/htdocs/form_select.html", "test/htdocs/form_select_all.html", "test/htdocs/form_select_none.html", "test/htdocs/form_select_noopts.html", "test/htdocs/form_set_fields.html", "test/htdocs/form_test.html", "test/htdocs/frame_test.html", "test/htdocs/google.html", "test/htdocs/iframe_test.html", "test/htdocs/index.html", "test/htdocs/link with space.html", "test/htdocs/meta_cookie.html", "test/htdocs/no_title_test.html", "test/htdocs/relative/tc_relative_links.html", "test/htdocs/tc_bad_links.html", "test/htdocs/tc_base_link.html", "test/htdocs/tc_blank_form.html", "test/htdocs/tc_checkboxes.html", "test/htdocs/tc_encoded_links.html", "test/htdocs/tc_follow_meta.html", "test/htdocs/tc_form_action.html", "test/htdocs/tc_links.html", "test/htdocs/tc_no_attributes.html", "test/htdocs/tc_pretty_print.html", "test/htdocs/tc_radiobuttons.html", "test/htdocs/tc_referer.html", "test/htdocs/tc_relative_links.html", "test/htdocs/tc_textarea.html", "test/htdocs/unusual______.html", "test/servlets.rb", "test/ssl_server.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_request.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{ http://mechanize.rubyforge.org/}
|
16
|
-
s.rdoc_options = ["--main", "README.
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{mechanize}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
20
|
s.summary = %q{Mechanize provides automated web-browsing}
|
21
|
-
s.test_files = ["test/chain/test_argument_validator.rb", "test/chain/test_custom_headers.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb"]
|
21
|
+
s.test_files = ["test/chain/test_argument_validator.rb", "test/chain/test_custom_headers.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_request.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
25
|
s.specification_version = 2
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 1.
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.
|
28
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 1.2.1"])
|
29
|
+
s.add_development_dependency(%q<hoe>, [">= 1.9.0"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<nokogiri>, [">= 1.
|
32
|
-
s.add_dependency(%q<hoe>, [">= 1.
|
31
|
+
s.add_dependency(%q<nokogiri>, [">= 1.2.1"])
|
32
|
+
s.add_dependency(%q<hoe>, [">= 1.9.0"])
|
33
33
|
end
|
34
34
|
else
|
35
|
-
s.add_dependency(%q<nokogiri>, [">= 1.
|
36
|
-
s.add_dependency(%q<hoe>, [">= 1.
|
35
|
+
s.add_dependency(%q<nokogiri>, [">= 1.2.1"])
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.9.0"])
|
37
37
|
end
|
38
38
|
end
|
data/test/test_cookie_class.rb
CHANGED
@@ -59,6 +59,15 @@ class CookieClassTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
def test_parse_weird_cookie
|
63
|
+
cookie = 'n/a, ASPSESSIONIDCSRRQDQR=FBLDGHPBNDJCPCGNCPAENELB; path=/'
|
64
|
+
url = URI.parse('http://www.searchinnovation.com/')
|
65
|
+
WWW::Mechanize::Cookie.parse(url, cookie) { |cookie|
|
66
|
+
assert_equal('ASPSESSIONIDCSRRQDQR', cookie.name)
|
67
|
+
assert_equal('FBLDGHPBNDJCPCGNCPAENELB', cookie.value)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
62
71
|
def test_double_semicolon
|
63
72
|
double_semi = 'WSIDC=WEST;; domain=.williams-sonoma.com; path=/'
|
64
73
|
url = URI.parse('http://williams-sonoma.com/')
|
data/test/test_forms.rb
CHANGED
@@ -12,6 +12,28 @@ class FormsMechTest < Test::Unit::TestCase
|
|
12
12
|
assert_match('/form_no_action.html?first=Aaron', page.uri.to_s)
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_submit_takes_arbirary_headers
|
16
|
+
page = @agent.get('http://localhost:2000/form_no_action.html')
|
17
|
+
assert form = page.forms.first
|
18
|
+
form.action = '/http_headers'
|
19
|
+
page = @agent.submit(form, nil, { 'foo' => 'bar' })
|
20
|
+
headers = Hash[*(
|
21
|
+
page.body.split("\n").map { |x| x.split('|') }.flatten
|
22
|
+
)]
|
23
|
+
assert_equal 'bar', headers['foo']
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_submit_takes_arbirary_headers
|
27
|
+
page = @agent.get('http://localhost:2000/form_no_action.html')
|
28
|
+
assert form = page.forms.first
|
29
|
+
form.action = '/http_headers'
|
30
|
+
page = form.submit(nil, { 'foo' => 'bar' })
|
31
|
+
headers = Hash[*(
|
32
|
+
page.body.split("\n").map { |x| x.split('|') }.flatten
|
33
|
+
)]
|
34
|
+
assert_equal 'bar', headers['foo']
|
35
|
+
end
|
36
|
+
|
15
37
|
# Test submitting form with two fields of the same name
|
16
38
|
def test_post_multival
|
17
39
|
page = @agent.get("http://localhost/form_multival.html")
|
@@ -72,6 +94,13 @@ class FormsMechTest < Test::Unit::TestCase
|
|
72
94
|
assert_not_nil(page.link_with(:text => 'first:Patterson'))
|
73
95
|
end
|
74
96
|
|
97
|
+
def test_post_with_non_strings
|
98
|
+
page = @agent.get("http://localhost/form_test.html")
|
99
|
+
page.form('post_form1') do |form|
|
100
|
+
form.first_name = 10
|
101
|
+
end.submit
|
102
|
+
end
|
103
|
+
|
75
104
|
def test_post
|
76
105
|
page = @agent.get("http://localhost/form_test.html")
|
77
106
|
post_form = page.forms.find { |f| f.name == "post_form1" }
|
data/test/test_mech.rb
CHANGED
@@ -10,6 +10,17 @@ class TestMechMethods < Test::Unit::TestCase
|
|
10
10
|
assert_equal('http://localhost/?foo=~2', page.uri.to_s)
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_submit_takes_arbirary_headers
|
14
|
+
page = @agent.get('http://localhost:2000/form_no_action.html')
|
15
|
+
assert form = page.forms.first
|
16
|
+
form.action = '/http_headers'
|
17
|
+
page = @agent.submit(form, nil, { 'foo' => 'bar' })
|
18
|
+
headers = Hash[*(
|
19
|
+
page.body.split("\n").map { |x| x.split('|') }.flatten
|
20
|
+
)]
|
21
|
+
assert_equal 'bar', headers['foo']
|
22
|
+
end
|
23
|
+
|
13
24
|
def test_get_with_params
|
14
25
|
page = @agent.get('http://localhost/', { :q => 'hello' })
|
15
26
|
assert_equal('http://localhost/?q=hello', page.uri.to_s)
|
data/test/test_page.rb
CHANGED
@@ -1,10 +1,28 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
2
2
|
|
3
|
+
require 'cgi'
|
4
|
+
|
3
5
|
class TestPage < Test::Unit::TestCase
|
4
6
|
def setup
|
5
7
|
@agent = WWW::Mechanize.new
|
6
8
|
end
|
7
9
|
|
10
|
+
def test_broken_charset
|
11
|
+
page = @agent.get("http://localhost/http_headers?content-type=#{CGI.escape('text/html; charset=akldsjfhaldjfksh')}")
|
12
|
+
assert page.parser
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_upper_case_content_type
|
16
|
+
page = @agent.get("http://localhost/http_headers?content-type=#{CGI.escape('text/HTML')}")
|
17
|
+
assert_instance_of WWW::Mechanize::Page, page
|
18
|
+
assert_equal 'text/HTML', page.content_type
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_page_gets_charset_sent_by_server
|
22
|
+
page = @agent.get("http://localhost/http_headers?content-type=#{CGI.escape('text/html; charset=UTF-8')}")
|
23
|
+
assert_equal 'UTF-8', page.encoding
|
24
|
+
end
|
25
|
+
|
8
26
|
def test_set_encoding
|
9
27
|
page = @agent.get("http://localhost/file_upload.html")
|
10
28
|
page.encoding = 'UTF-8'
|
data/test/test_radiobutton.rb
CHANGED
@@ -60,4 +60,16 @@ class TestRadioButtons < Test::Unit::TestCase
|
|
60
60
|
).checked)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
def test_click_all
|
65
|
+
form = @page.forms.first
|
66
|
+
form.radiobuttons_with(:name => 'color').each do |button|
|
67
|
+
button.click
|
68
|
+
end
|
69
|
+
c = form.radiobuttons_with(:name => 'color').inject(0) do |m,button|
|
70
|
+
m += 1 if button.checked
|
71
|
+
m
|
72
|
+
end
|
73
|
+
assert_equal 1, c, 'Only one radio button should be checked'
|
74
|
+
end
|
63
75
|
end
|
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.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-03-05 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -42,21 +42,21 @@ executables: []
|
|
42
42
|
extensions: []
|
43
43
|
|
44
44
|
extra_rdoc_files:
|
45
|
-
- EXAMPLES.txt
|
46
|
-
- FAQ.txt
|
47
|
-
- GUIDE.txt
|
48
|
-
- History.txt
|
49
|
-
- LICENSE.txt
|
50
45
|
- Manifest.txt
|
51
|
-
-
|
46
|
+
- CHANGELOG.rdoc
|
47
|
+
- EXAMPLES.rdoc
|
48
|
+
- FAQ.rdoc
|
49
|
+
- GUIDE.rdoc
|
50
|
+
- LICENSE.rdoc
|
51
|
+
- README.rdoc
|
52
52
|
files:
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
- LICENSE.
|
53
|
+
- CHANGELOG.rdoc
|
54
|
+
- EXAMPLES.rdoc
|
55
|
+
- FAQ.rdoc
|
56
|
+
- GUIDE.rdoc
|
57
|
+
- LICENSE.rdoc
|
58
58
|
- Manifest.txt
|
59
|
-
- README.
|
59
|
+
- README.rdoc
|
60
60
|
- Rakefile
|
61
61
|
- examples/flickr_upload.rb
|
62
62
|
- examples/mech-dump.rb
|
@@ -224,7 +224,7 @@ homepage: " http://mechanize.rubyforge.org/"
|
|
224
224
|
post_install_message:
|
225
225
|
rdoc_options:
|
226
226
|
- --main
|
227
|
-
- README.
|
227
|
+
- README.rdoc
|
228
228
|
require_paths:
|
229
229
|
- lib
|
230
230
|
required_ruby_version: !ruby/object:Gem::Requirement
|