mechanize 0.4.7 → 0.5.0
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/CHANGELOG +17 -0
- data/EXAMPLES +23 -44
- data/NOTES +49 -0
- data/lib/mechanize.rb +95 -80
- data/lib/mechanize/cookie.rb +147 -148
- data/lib/mechanize/cookie.rb.rej +16 -0
- data/lib/mechanize/errors.rb +29 -0
- data/lib/mechanize/form.rb +211 -186
- data/lib/mechanize/form_elements.rb +31 -71
- data/lib/mechanize/list.rb +34 -0
- data/lib/mechanize/mech_version.rb +3 -1
- data/lib/mechanize/module.rb +1 -1
- data/lib/mechanize/page.rb +162 -180
- data/lib/mechanize/page_elements.rb +53 -40
- data/lib/mechanize/parsing.rb +11 -3
- data/lib/mechanize/pluggable_parsers.rb +147 -0
- data/test/data/server.crt +14 -0
- data/test/data/server.csr +11 -0
- data/test/data/server.key +18 -0
- data/test/data/server.pem +15 -0
- data/test/htdocs/no_title_test.html +6 -0
- data/test/parse.rb +39 -0
- data/test/proxy.rb +30 -0
- data/test/server.rb +2 -0
- data/test/servlets.rb +8 -0
- data/test/ssl_server.rb +49 -0
- data/test/tc_authenticate.rb +8 -6
- data/test/tc_cookie_class.rb +28 -18
- data/test/tc_cookie_jar.rb +88 -27
- data/test/tc_cookies.rb +41 -44
- data/test/tc_errors.rb +9 -23
- data/test/tc_forms.rb +36 -32
- data/test/tc_frames.rb +6 -4
- data/test/tc_links.rb +7 -6
- data/test/tc_mech.rb +43 -46
- data/test/tc_page.rb +24 -0
- data/test/tc_pluggable_parser.rb +103 -0
- data/test/tc_post_form.rb +41 -0
- data/test/tc_proxy.rb +25 -0
- data/test/tc_response_code.rb +13 -10
- data/test/tc_save_file.rb +25 -0
- data/test/tc_ssl_server.rb +27 -0
- data/test/tc_upload.rb +8 -6
- data/test/tc_watches.rb +5 -2
- data/test/test_includes.rb +3 -3
- data/test/ts_mech.rb +11 -2
- metadata +100 -86
- data/test/tc_filter.rb +0 -34
data/test/tc_upload.rb
CHANGED
@@ -8,9 +8,12 @@ require 'test_includes'
|
|
8
8
|
class UploadMechTest < Test::Unit::TestCase
|
9
9
|
include TestMethods
|
10
10
|
|
11
|
+
def setup
|
12
|
+
@agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
|
13
|
+
end
|
14
|
+
|
11
15
|
def test_form_enctype
|
12
|
-
|
13
|
-
page = agent.get("http://localhost:#{@port}/file_upload.html")
|
16
|
+
page = @agent.get("http://localhost:#{PORT}/file_upload.html")
|
14
17
|
assert_equal('multipart/form-data', page.forms[0].enctype)
|
15
18
|
|
16
19
|
form = page.forms.first
|
@@ -18,7 +21,7 @@ class UploadMechTest < Test::Unit::TestCase
|
|
18
21
|
form.file_uploads.first.mime_type = "text/plain"
|
19
22
|
form.file_uploads.first.file_data = "Hello World\n\n"
|
20
23
|
|
21
|
-
page = agent.submit(form)
|
24
|
+
page = @agent.submit(form)
|
22
25
|
|
23
26
|
assert_match(
|
24
27
|
"Content-Disposition: form-data; name=\"userfile1\"; filename=\"README\"",
|
@@ -34,8 +37,7 @@ class UploadMechTest < Test::Unit::TestCase
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def test_form_multipart
|
37
|
-
|
38
|
-
page = agent.get("http://localhost:#{@port}/file_upload.html")
|
40
|
+
page = @agent.get("http://localhost:#{PORT}/file_upload.html")
|
39
41
|
assert_equal('multipart/form-data', page.forms[1].enctype)
|
40
42
|
|
41
43
|
form = page.forms[1]
|
@@ -43,7 +45,7 @@ class UploadMechTest < Test::Unit::TestCase
|
|
43
45
|
form.file_uploads.first.mime_type = "text/plain"
|
44
46
|
form.file_uploads.first.file_data = "Hello World\n\n"
|
45
47
|
|
46
|
-
page = agent.submit(form)
|
48
|
+
page = @agent.submit(form)
|
47
49
|
|
48
50
|
assert_match(
|
49
51
|
"Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"README\"",
|
data/test/tc_watches.rb
CHANGED
@@ -16,9 +16,12 @@ end
|
|
16
16
|
class WatchesMechTest < Test::Unit::TestCase
|
17
17
|
include TestMethods
|
18
18
|
|
19
|
+
def setup
|
20
|
+
@agent = WWW::Mechanize.new
|
21
|
+
end
|
22
|
+
|
19
23
|
def test_watches
|
20
|
-
|
21
|
-
page = agent.get("http://localhost:#{@port}/find_link.html")
|
24
|
+
page = @agent.get("http://localhost:#{PORT}/find_link.html")
|
22
25
|
page.watch_for_set = { 'area' => Area }
|
23
26
|
watches = page.watches
|
24
27
|
assert_equal(3, watches['area'].size)
|
data/test/test_includes.rb
CHANGED
data/test/ts_mech.rb
CHANGED
@@ -2,9 +2,13 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
|
2
2
|
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
3
|
|
4
4
|
Thread.new {
|
5
|
-
require 'server'
|
5
|
+
require 'server'
|
6
6
|
}
|
7
7
|
|
8
|
+
#Thread.new {
|
9
|
+
# require 'ssl_server'
|
10
|
+
#}
|
11
|
+
|
8
12
|
require 'test/unit'
|
9
13
|
require 'tc_cookies'
|
10
14
|
require 'tc_forms'
|
@@ -16,8 +20,13 @@ require 'tc_forms'
|
|
16
20
|
require 'tc_watches'
|
17
21
|
require 'tc_parsing'
|
18
22
|
require 'tc_authenticate'
|
19
|
-
require 'tc_filter'
|
20
23
|
require 'tc_cookie_class'
|
21
24
|
require 'tc_cookie_jar'
|
22
25
|
require 'tc_errors'
|
26
|
+
require 'tc_save_file'
|
27
|
+
require 'tc_post_form'
|
28
|
+
require 'tc_pluggable_parser'
|
29
|
+
require 'tc_page'
|
30
|
+
#require 'tc_proxy'
|
31
|
+
#require 'tc_ssl_server'
|
23
32
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: mechanize
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2006-07-05 00:00:00 -07:00
|
8
8
|
summary: Mechanize provides automated web-browsing
|
9
9
|
require_paths:
|
10
|
-
- lib
|
10
|
+
- lib
|
11
11
|
email: aaronp@rubyforge.org
|
12
12
|
homepage: mechanize.rubyforge.org
|
13
13
|
rubyforge_project: mechanize
|
@@ -18,99 +18,113 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
24
25
|
version:
|
25
26
|
platform: ruby
|
26
27
|
signing_key:
|
27
28
|
cert_chain:
|
28
29
|
post_install_message:
|
29
30
|
authors:
|
30
|
-
- Aaron Patterson
|
31
|
+
- Aaron Patterson
|
31
32
|
files:
|
32
|
-
- test/
|
33
|
-
- test/
|
34
|
-
- test/
|
35
|
-
- test/
|
36
|
-
- test/
|
37
|
-
- test/
|
38
|
-
- test/
|
39
|
-
- test/
|
40
|
-
- test/
|
41
|
-
- test/
|
42
|
-
- test/
|
43
|
-
- test/
|
44
|
-
- test/
|
45
|
-
- test/
|
46
|
-
- test/
|
47
|
-
- test/
|
48
|
-
- test/tc_mech.rb
|
49
|
-
- test/
|
50
|
-
- test/
|
51
|
-
- test/
|
52
|
-
- test/
|
53
|
-
- test/
|
54
|
-
- test/
|
55
|
-
- test/
|
56
|
-
- test/
|
57
|
-
- test/
|
58
|
-
- test/
|
59
|
-
- test/
|
60
|
-
- test/
|
61
|
-
- test/
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/
|
65
|
-
- test/
|
66
|
-
- test/data/
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
- lib/mechanize
|
81
|
-
- lib/mechanize
|
82
|
-
- lib/mechanize/
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
33
|
+
- test/data
|
34
|
+
- test/htdocs
|
35
|
+
- test/parse.rb
|
36
|
+
- test/proxy.rb
|
37
|
+
- test/README
|
38
|
+
- test/server.rb
|
39
|
+
- test/servlets.rb
|
40
|
+
- test/ssl_server.rb
|
41
|
+
- test/tc_authenticate.rb
|
42
|
+
- test/tc_cookie_class.rb
|
43
|
+
- test/tc_cookie_jar.rb
|
44
|
+
- test/tc_cookies.rb
|
45
|
+
- test/tc_errors.rb
|
46
|
+
- test/tc_forms.rb
|
47
|
+
- test/tc_frames.rb
|
48
|
+
- test/tc_links.rb
|
49
|
+
- test/tc_mech.rb
|
50
|
+
- test/tc_page.rb
|
51
|
+
- test/tc_parsing.rb
|
52
|
+
- test/tc_pluggable_parser.rb
|
53
|
+
- test/tc_post_form.rb
|
54
|
+
- test/tc_proxy.rb
|
55
|
+
- test/tc_response_code.rb
|
56
|
+
- test/tc_save_file.rb
|
57
|
+
- test/tc_ssl_server.rb
|
58
|
+
- test/tc_upload.rb
|
59
|
+
- test/tc_watches.rb
|
60
|
+
- test/test_includes.rb
|
61
|
+
- test/test_mech.rb
|
62
|
+
- test/ts_mech.rb
|
63
|
+
- test/data/htpasswd
|
64
|
+
- test/data/server.crt
|
65
|
+
- test/data/server.csr
|
66
|
+
- test/data/server.key
|
67
|
+
- test/data/server.pem
|
68
|
+
- test/htdocs/alt_text.html
|
69
|
+
- test/htdocs/bad_form_test.html
|
70
|
+
- test/htdocs/button.jpg
|
71
|
+
- test/htdocs/file_upload.html
|
72
|
+
- test/htdocs/find_link.html
|
73
|
+
- test/htdocs/form_multival.html
|
74
|
+
- test/htdocs/form_no_action.html
|
75
|
+
- test/htdocs/form_test.html
|
76
|
+
- test/htdocs/frame_test.html
|
77
|
+
- test/htdocs/google.html
|
78
|
+
- test/htdocs/iframe_test.html
|
79
|
+
- test/htdocs/index.html
|
80
|
+
- test/htdocs/no_title_test.html
|
81
|
+
- lib/mechanize
|
82
|
+
- lib/mechanize.rb
|
83
|
+
- lib/mechanize/cookie.rb
|
84
|
+
- lib/mechanize/cookie.rb.rej
|
85
|
+
- lib/mechanize/errors.rb
|
86
|
+
- lib/mechanize/form.rb
|
87
|
+
- lib/mechanize/form_elements.rb
|
88
|
+
- lib/mechanize/list.rb
|
89
|
+
- lib/mechanize/mech_version.rb
|
90
|
+
- lib/mechanize/module.rb
|
91
|
+
- lib/mechanize/net-overrides
|
92
|
+
- lib/mechanize/page.rb
|
93
|
+
- lib/mechanize/page_elements.rb
|
94
|
+
- lib/mechanize/parsing.rb
|
95
|
+
- lib/mechanize/pluggable_parsers.rb
|
96
|
+
- lib/mechanize/net-overrides/net
|
97
|
+
- lib/mechanize/net-overrides/net/http.rb
|
98
|
+
- lib/mechanize/net-overrides/net/https.rb
|
99
|
+
- lib/mechanize/net-overrides/net/protocol.rb
|
100
|
+
- README
|
101
|
+
- EXAMPLES
|
102
|
+
- CHANGELOG
|
103
|
+
- LICENSE
|
104
|
+
- NOTES
|
88
105
|
test_files: []
|
89
|
-
|
90
106
|
rdoc_options:
|
91
|
-
- --main
|
92
|
-
- README
|
93
|
-
- --title
|
94
|
-
- "'WWW::Mechanize RDoc'"
|
107
|
+
- "--main"
|
108
|
+
- README
|
109
|
+
- "--title"
|
110
|
+
- "'WWW::Mechanize RDoc'"
|
95
111
|
extra_rdoc_files:
|
96
|
-
- README
|
97
|
-
- EXAMPLES
|
98
|
-
- CHANGELOG
|
99
|
-
- LICENSE
|
100
|
-
- NOTES
|
112
|
+
- README
|
113
|
+
- EXAMPLES
|
114
|
+
- CHANGELOG
|
115
|
+
- LICENSE
|
116
|
+
- NOTES
|
101
117
|
executables: []
|
102
|
-
|
103
118
|
extensions: []
|
104
|
-
|
105
119
|
requirements: []
|
106
|
-
|
107
120
|
dependencies:
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: ruby-web
|
123
|
+
version_requirement:
|
124
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
125
|
+
requirements:
|
126
|
+
-
|
127
|
+
- ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 1.1.0
|
130
|
+
version:
|
data/test/tc_filter.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
7
|
-
|
8
|
-
class FilterTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
|
-
def test_local_filter
|
12
|
-
agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
|
13
|
-
page = agent.get("http://localhost:#{@port}/find_link.html")
|
14
|
-
page.body_filter = lambda { |body| body.gsub(/<body>/, '<body><a href="http://daapclient.rubyforge.org">Net::DAAP::Client</a>') }
|
15
|
-
assert_equal(16, page.links.length)
|
16
|
-
assert_not_nil(page.links.text('Net::DAAP::Client').first)
|
17
|
-
assert_equal(1, page.links.text('Net::DAAP::Client').length)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_global_filter
|
21
|
-
agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
|
22
|
-
agent.body_filter = lambda { |body| body.gsub(/<body>/, '<body><a href="http://daapclient.rubyforge.org">Net::DAAP::Client</a>') }
|
23
|
-
page = agent.get("http://localhost:#{@port}/find_link.html")
|
24
|
-
assert_equal(16, page.links.length)
|
25
|
-
assert_not_nil(page.links.text('Net::DAAP::Client').first)
|
26
|
-
assert_equal(1, page.links.text('Net::DAAP::Client').length)
|
27
|
-
|
28
|
-
page = agent.get("http://localhost:#{@port}/find_link.html")
|
29
|
-
page.body_filter = lambda { |body| body.gsub(/<body>/, '<body><a href="http://daapclient.rubyforge.org">Net::DAAP::Client</a>') }
|
30
|
-
assert_equal(17, page.links.length)
|
31
|
-
assert_not_nil(page.links.text('Net::DAAP::Client').first)
|
32
|
-
assert_equal(2, page.links.text('Net::DAAP::Client').length)
|
33
|
-
end
|
34
|
-
end
|