tenderlove-mechanize 0.9.3.20090623142847 → 0.9.3.20090911221705
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +55 -48
- data/Rakefile +12 -22
- data/lib/mechanize.rb +618 -4
- data/lib/mechanize/chain.rb +33 -0
- data/lib/mechanize/chain/auth_headers.rb +78 -0
- data/lib/mechanize/chain/body_decoding_handler.rb +46 -0
- data/lib/mechanize/chain/connection_resolver.rb +76 -0
- data/lib/mechanize/chain/custom_headers.rb +21 -0
- data/lib/{www/mechanize → mechanize}/chain/handler.rb +1 -1
- data/lib/mechanize/chain/header_resolver.rb +51 -0
- data/lib/mechanize/chain/parameter_resolver.rb +22 -0
- data/lib/{www/mechanize → mechanize}/chain/post_connect_hook.rb +0 -0
- data/lib/mechanize/chain/pre_connect_hook.rb +20 -0
- data/lib/mechanize/chain/request_resolver.rb +30 -0
- data/lib/mechanize/chain/response_body_parser.rb +38 -0
- data/lib/mechanize/chain/response_header_handler.rb +48 -0
- data/lib/mechanize/chain/response_reader.rb +39 -0
- data/lib/mechanize/chain/ssl_resolver.rb +40 -0
- data/lib/mechanize/chain/uri_resolver.rb +75 -0
- data/lib/mechanize/content_type_error.rb +14 -0
- data/lib/mechanize/cookie.rb +70 -0
- data/lib/mechanize/cookie_jar.rb +188 -0
- data/lib/mechanize/file.rb +71 -0
- data/lib/mechanize/file_response.rb +60 -0
- data/lib/mechanize/file_saver.rb +37 -0
- data/lib/mechanize/form.rb +378 -0
- data/lib/mechanize/form/button.rb +9 -0
- data/lib/mechanize/form/check_box.rb +11 -0
- data/lib/mechanize/form/field.rb +30 -0
- data/lib/mechanize/form/file_upload.rb +22 -0
- data/lib/mechanize/form/image_button.rb +21 -0
- data/lib/mechanize/form/multi_select_list.rb +67 -0
- data/lib/mechanize/form/option.rb +49 -0
- data/lib/mechanize/form/radio_button.rb +49 -0
- data/lib/mechanize/form/select_list.rb +43 -0
- data/lib/mechanize/headers.rb +11 -0
- data/lib/mechanize/history.rb +65 -0
- data/lib/mechanize/inspect.rb +88 -0
- data/lib/{www/mechanize → mechanize}/monkey_patch.rb +4 -6
- data/lib/mechanize/page.rb +206 -0
- data/lib/mechanize/page/base.rb +8 -0
- data/lib/mechanize/page/frame.rb +20 -0
- data/lib/mechanize/page/image.rb +26 -0
- data/lib/mechanize/page/label.rb +20 -0
- data/lib/mechanize/page/link.rb +48 -0
- data/lib/mechanize/page/meta.rb +50 -0
- data/lib/mechanize/pluggable_parsers.rb +101 -0
- data/lib/mechanize/redirect_limit_reached_error.rb +16 -0
- data/lib/mechanize/redirect_not_get_or_head_error.rb +18 -0
- data/lib/mechanize/response_code_error.rb +22 -0
- data/lib/mechanize/unsupported_scheme_error.rb +8 -0
- data/lib/mechanize/util.rb +67 -0
- data/mechanize.gemspec +8 -8
- data/test/chain/test_argument_validator.rb +2 -2
- data/test/chain/test_auth_headers.rb +2 -2
- data/test/chain/test_custom_headers.rb +2 -2
- data/test/chain/test_header_resolver.rb +3 -3
- data/test/chain/test_parameter_resolver.rb +4 -4
- data/test/chain/test_request_resolver.rb +4 -4
- data/test/chain/test_response_reader.rb +3 -3
- data/test/helper.rb +1 -1
- data/test/htdocs/tc_bad_charset.html +9 -0
- data/test/htdocs/tc_charset.html +6 -0
- data/test/htdocs/test_bad_encoding.html +52 -0
- data/test/test_authenticate.rb +3 -3
- data/test/test_bad_links.rb +1 -1
- data/test/test_blank_form.rb +1 -1
- data/test/test_checkboxes.rb +1 -1
- data/test/test_content_type.rb +2 -2
- data/test/test_cookie_class.rb +12 -12
- data/test/test_cookie_jar.rb +13 -13
- data/test/test_cookies.rb +1 -1
- data/test/test_encoded_links.rb +1 -1
- data/test/test_errors.rb +2 -2
- data/test/test_follow_meta.rb +3 -3
- data/test/test_form_action.rb +1 -1
- data/test/test_form_as_hash.rb +1 -1
- data/test/test_form_button.rb +2 -2
- data/test/test_form_no_inputname.rb +1 -1
- data/test/test_forms.rb +1 -1
- data/test/test_frames.rb +1 -1
- data/test/test_get_headers.rb +1 -1
- data/test/test_gzipping.rb +2 -2
- data/test/test_hash_api.rb +1 -1
- data/test/test_history.rb +7 -7
- data/test/test_history_added.rb +1 -1
- data/test/test_html_unscape_forms.rb +7 -7
- data/test/test_if_modified_since.rb +1 -1
- data/test/test_keep_alive.rb +1 -1
- data/test/test_links.rb +2 -2
- data/test/test_mech.rb +2 -2
- data/test/test_mechanize_file.rb +7 -7
- data/test/test_meta.rb +2 -2
- data/test/test_multi_select.rb +1 -1
- data/test/test_no_attributes.rb +1 -1
- data/test/test_option.rb +1 -1
- data/test/test_page.rb +3 -3
- data/test/test_pluggable_parser.rb +14 -14
- data/test/test_post_form.rb +1 -1
- data/test/test_pretty_print.rb +2 -2
- data/test/test_radiobutton.rb +1 -1
- data/test/test_redirect_limit_reached.rb +1 -3
- data/test/test_redirect_verb_handling.rb +1 -3
- data/test/test_referer.rb +1 -1
- data/test/test_relative_links.rb +1 -1
- data/test/test_request.rb +1 -1
- data/test/test_response_code.rb +3 -3
- data/test/test_save_file.rb +3 -3
- data/test/test_scheme.rb +3 -3
- data/test/test_select.rb +2 -2
- data/test/test_select_all.rb +1 -1
- data/test/test_select_none.rb +1 -1
- data/test/test_select_noopts.rb +1 -1
- data/test/test_set_fields.rb +1 -1
- data/test/test_ssl_server.rb +1 -1
- data/test/test_subclass.rb +1 -1
- data/test/test_textarea.rb +1 -1
- data/test/test_upload.rb +1 -1
- data/test/test_verbs.rb +1 -1
- metadata +61 -56
- data/lib/www/mechanize.rb +0 -619
- data/lib/www/mechanize/chain.rb +0 -34
- data/lib/www/mechanize/chain/auth_headers.rb +0 -80
- data/lib/www/mechanize/chain/body_decoding_handler.rb +0 -48
- data/lib/www/mechanize/chain/connection_resolver.rb +0 -78
- data/lib/www/mechanize/chain/custom_headers.rb +0 -23
- data/lib/www/mechanize/chain/header_resolver.rb +0 -53
- data/lib/www/mechanize/chain/parameter_resolver.rb +0 -24
- data/lib/www/mechanize/chain/pre_connect_hook.rb +0 -22
- data/lib/www/mechanize/chain/request_resolver.rb +0 -32
- data/lib/www/mechanize/chain/response_body_parser.rb +0 -40
- data/lib/www/mechanize/chain/response_header_handler.rb +0 -50
- data/lib/www/mechanize/chain/response_reader.rb +0 -41
- data/lib/www/mechanize/chain/ssl_resolver.rb +0 -42
- data/lib/www/mechanize/chain/uri_resolver.rb +0 -77
- data/lib/www/mechanize/content_type_error.rb +0 -16
- data/lib/www/mechanize/cookie.rb +0 -72
- data/lib/www/mechanize/cookie_jar.rb +0 -191
- data/lib/www/mechanize/file.rb +0 -73
- data/lib/www/mechanize/file_response.rb +0 -62
- data/lib/www/mechanize/file_saver.rb +0 -39
- data/lib/www/mechanize/form.rb +0 -360
- data/lib/www/mechanize/form/button.rb +0 -8
- data/lib/www/mechanize/form/check_box.rb +0 -13
- data/lib/www/mechanize/form/field.rb +0 -28
- data/lib/www/mechanize/form/file_upload.rb +0 -24
- data/lib/www/mechanize/form/image_button.rb +0 -23
- data/lib/www/mechanize/form/multi_select_list.rb +0 -69
- data/lib/www/mechanize/form/option.rb +0 -51
- data/lib/www/mechanize/form/radio_button.rb +0 -38
- data/lib/www/mechanize/form/select_list.rb +0 -45
- data/lib/www/mechanize/headers.rb +0 -12
- data/lib/www/mechanize/history.rb +0 -67
- data/lib/www/mechanize/inspect.rb +0 -90
- data/lib/www/mechanize/page.rb +0 -181
- data/lib/www/mechanize/page/base.rb +0 -10
- data/lib/www/mechanize/page/frame.rb +0 -22
- data/lib/www/mechanize/page/link.rb +0 -50
- data/lib/www/mechanize/page/meta.rb +0 -51
- data/lib/www/mechanize/pluggable_parsers.rb +0 -103
- data/lib/www/mechanize/redirect_limit_reached_error.rb +0 -18
- data/lib/www/mechanize/redirect_not_get_or_head_error.rb +0 -20
- data/lib/www/mechanize/response_code_error.rb +0 -25
- data/lib/www/mechanize/unsupported_scheme_error.rb +0 -10
- data/lib/www/mechanize/util.rb +0 -76
data/test/test_keep_alive.rb
CHANGED
data/test/test_links.rb
CHANGED
@@ -2,13 +2,13 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class LinksMechTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_unsupported_link_types
|
9
9
|
page = @agent.get("http://google.com/tc_links.html")
|
10
10
|
link = page.link_with(:text => 'javascript link')
|
11
|
-
assert_raise(
|
11
|
+
assert_raise(Mechanize::UnsupportedSchemeError) {
|
12
12
|
link.click
|
13
13
|
}
|
14
14
|
|
data/test/test_mech.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class TestMechMethods < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_get_with_tilde
|
@@ -82,7 +82,7 @@ class TestMechMethods < Test::Unit::TestCase
|
|
82
82
|
|
83
83
|
def test_get_with_file_referer
|
84
84
|
assert_nothing_raised do
|
85
|
-
@agent.get('http://localhost', [],
|
85
|
+
@agent.get('http://localhost', [], Mechanize::File.new(URI.parse('http://tenderlovemaking.com/crossdomain.xml')))
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/test/test_mechanize_file.rb
CHANGED
@@ -2,19 +2,19 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class MechanizeFileTest < Test::Unit::TestCase
|
4
4
|
def test_content_disposition
|
5
|
-
file =
|
5
|
+
file = Mechanize::File.new(
|
6
6
|
URI.parse('http://localhost/foo'),
|
7
7
|
{ 'content-disposition' => 'attachment; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"', }
|
8
8
|
)
|
9
9
|
assert_equal('genome.jpeg', file.filename)
|
10
10
|
|
11
|
-
file =
|
11
|
+
file = Mechanize::File.new(
|
12
12
|
URI.parse('http://localhost/foo'),
|
13
13
|
{ 'content-disposition' => 'filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"', }
|
14
14
|
)
|
15
15
|
assert_equal('genome.jpeg', file.filename)
|
16
16
|
|
17
|
-
file =
|
17
|
+
file = Mechanize::File.new(
|
18
18
|
URI.parse('http://localhost/foo'),
|
19
19
|
{ 'content-disposition' => 'filename=genome.jpeg', }
|
20
20
|
)
|
@@ -22,26 +22,26 @@ class MechanizeFileTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_from_uri
|
25
|
-
file =
|
25
|
+
file = Mechanize::File.new(
|
26
26
|
URI.parse('http://localhost/foo'),
|
27
27
|
{}
|
28
28
|
)
|
29
29
|
assert_equal('foo.html', file.filename)
|
30
30
|
|
31
|
-
file =
|
31
|
+
file = Mechanize::File.new(
|
32
32
|
URI.parse('http://localhost/foo.jpg'),
|
33
33
|
{}
|
34
34
|
)
|
35
35
|
assert_equal('foo.jpg', file.filename)
|
36
36
|
|
37
|
-
file =
|
37
|
+
file = Mechanize::File.new(
|
38
38
|
URI.parse('http://localhost/foo.jpg')
|
39
39
|
)
|
40
40
|
assert_equal('foo.jpg', file.filename)
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_no_uri
|
44
|
-
file =
|
44
|
+
file = Mechanize::File.new()
|
45
45
|
assert_equal('index.html', file.filename)
|
46
46
|
end
|
47
47
|
end
|
data/test/test_meta.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
2
2
|
|
3
3
|
class MetaTest < Test::Unit::TestCase
|
4
|
-
Meta =
|
4
|
+
Meta = Mechanize::Page::Meta
|
5
5
|
|
6
6
|
#
|
7
7
|
# CONTENT_REGEXP test
|
@@ -62,4 +62,4 @@ class MetaTest < Test::Unit::TestCase
|
|
62
62
|
assert_equal nil, Meta.parse("invalid content", uri)
|
63
63
|
assert_equal nil, Meta.parse("invalid content", uri) {|delay, url| 'not nil' }
|
64
64
|
end
|
65
|
-
end
|
65
|
+
end
|
data/test/test_multi_select.rb
CHANGED
data/test/test_no_attributes.rb
CHANGED
data/test/test_option.rb
CHANGED
@@ -12,7 +12,7 @@ class OptionTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
def test_option_missing_value
|
14
14
|
attribute = FakeAttribute.new('blah')
|
15
|
-
option =
|
15
|
+
option = Mechanize::Form::Option.new(attribute, nil)
|
16
16
|
assert_equal('blah', option.value)
|
17
17
|
end
|
18
18
|
end
|
data/test/test_page.rb
CHANGED
@@ -4,7 +4,7 @@ require 'cgi'
|
|
4
4
|
|
5
5
|
class TestPage < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@agent =
|
7
|
+
@agent = Mechanize.new
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_page_gets_charset_from_page
|
@@ -35,7 +35,7 @@ class TestPage < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
def test_upper_case_content_type
|
37
37
|
page = @agent.get("http://localhost/http_headers?content-type=#{CGI.escape('text/HTML')}")
|
38
|
-
assert_instance_of
|
38
|
+
assert_instance_of Mechanize::Page, page
|
39
39
|
assert_equal 'text/HTML', page.content_type
|
40
40
|
end
|
41
41
|
|
@@ -89,7 +89,7 @@ class TestPage < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_page_decoded_with_charset
|
92
|
-
page =
|
92
|
+
page = Mechanize::Page.new(
|
93
93
|
URI.parse('http://tenderlovemaking.com/'),
|
94
94
|
{ 'content-type' => 'text/html; charset=EUC-JP' },
|
95
95
|
'<html><body>hello</body></html>',
|
@@ -2,13 +2,13 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class PluggableParserTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_content_type_error
|
9
9
|
page = @agent.get("http://localhost/bad_content_type")
|
10
|
-
assert_raise(
|
11
|
-
page =
|
10
|
+
assert_raise(Mechanize::ContentTypeError) {
|
11
|
+
page = Mechanize::Page.new(
|
12
12
|
page.uri,
|
13
13
|
page.response,
|
14
14
|
page.body,
|
@@ -16,23 +16,23 @@ class PluggableParserTest < Test::Unit::TestCase
|
|
16
16
|
)
|
17
17
|
}
|
18
18
|
begin
|
19
|
-
page =
|
19
|
+
page = Mechanize::Page.new(
|
20
20
|
page.uri,
|
21
21
|
page.response,
|
22
22
|
page.body,
|
23
23
|
page.code
|
24
24
|
)
|
25
|
-
rescue
|
25
|
+
rescue Mechanize::ContentTypeError => ex
|
26
26
|
assert_equal('text/xml', ex.content_type)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_content_type
|
31
31
|
page = @agent.get("http://localhost/content_type_test")
|
32
|
-
assert_kind_of(
|
32
|
+
assert_kind_of(Mechanize::Page, page)
|
33
33
|
end
|
34
34
|
|
35
|
-
class Filter <
|
35
|
+
class Filter < Mechanize::Page
|
36
36
|
def initialize(uri=nil, response=nil, body=nil, code=nil)
|
37
37
|
super( uri,
|
38
38
|
response,
|
@@ -42,7 +42,7 @@ class PluggableParserTest < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
class FileFilter <
|
45
|
+
class FileFilter < Mechanize::File
|
46
46
|
def initialize(uri=nil, response=nil, body=nil, code=nil)
|
47
47
|
super( uri,
|
48
48
|
response,
|
@@ -73,7 +73,7 @@ class PluggableParserTest < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_file_saver
|
76
|
-
@agent.pluggable_parser.html =
|
76
|
+
@agent.pluggable_parser.html = Mechanize::FileSaver
|
77
77
|
page = @agent.get('http://localhost:2000/form_no_action.html')
|
78
78
|
length = page.response['Content-Length']
|
79
79
|
file_length = nil
|
@@ -110,35 +110,35 @@ class PluggableParserTest < Test::Unit::TestCase
|
|
110
110
|
|
111
111
|
def test_file_saver_no_path
|
112
112
|
url = URI::HTTP.new('http', nil, 'example.com', nil, nil, '', nil, nil, nil)
|
113
|
-
fs =
|
113
|
+
fs = Mechanize::FileSaver.new(url, nil, 'hello world', 200)
|
114
114
|
assert_equal('example.com/index.html', fs.filename)
|
115
115
|
FileUtils.rm_rf('example.com')
|
116
116
|
end
|
117
117
|
|
118
118
|
def test_file_saver_slash
|
119
119
|
url = URI::HTTP.new('http', nil, 'example.com', nil, nil, '/', nil, nil, nil)
|
120
|
-
fs =
|
120
|
+
fs = Mechanize::FileSaver.new(url, nil, 'hello world', 200)
|
121
121
|
assert_equal('example.com/index.html', fs.filename)
|
122
122
|
FileUtils.rm_rf('example.com')
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_file_saver_slash_file
|
126
126
|
url = URI::HTTP.new('http', nil, 'example.com', nil, nil, '/foo.html', nil, nil, nil)
|
127
|
-
fs =
|
127
|
+
fs = Mechanize::FileSaver.new(url, nil, 'hello world', 200)
|
128
128
|
assert_equal('example.com/foo.html', fs.filename)
|
129
129
|
FileUtils.rm_rf('example.com')
|
130
130
|
end
|
131
131
|
|
132
132
|
def test_file_saver_long_path_no_file
|
133
133
|
url = URI::HTTP.new('http', nil, 'example.com', nil, nil, '/one/two/', nil, nil, nil)
|
134
|
-
fs =
|
134
|
+
fs = Mechanize::FileSaver.new(url, nil, 'hello world', 200)
|
135
135
|
assert_equal('example.com/one/two/index.html', fs.filename)
|
136
136
|
FileUtils.rm_rf('example.com')
|
137
137
|
end
|
138
138
|
|
139
139
|
def test_file_saver_long_path
|
140
140
|
url = URI::HTTP.new('http', nil, 'example.com', nil, nil, '/one/two/foo.html', nil, nil, nil)
|
141
|
-
fs =
|
141
|
+
fs = Mechanize::FileSaver.new(url, nil, 'hello world', 200)
|
142
142
|
assert_equal('example.com/one/two/foo.html', fs.filename)
|
143
143
|
FileUtils.rm_rf('example.com')
|
144
144
|
end
|
data/test/test_post_form.rb
CHANGED
data/test/test_pretty_print.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class TestPrettyPrint < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_pretty_print
|
@@ -12,7 +12,7 @@ class TestPrettyPrint < Test::Unit::TestCase
|
|
12
12
|
assert_match(/\{frames[^"]*"http:\/\/meme/, pretty_string)
|
13
13
|
assert_match(/\{iframes[^"]*"http:\/\/meme/, pretty_string)
|
14
14
|
assert_match(
|
15
|
-
"{links #<
|
15
|
+
"{links #<Mechanize::Page::Link \"Google\" \"http://google.com/\">}",
|
16
16
|
pretty_string
|
17
17
|
)
|
18
18
|
assert_match("form1", pretty_string)
|
data/test/test_radiobutton.rb
CHANGED
data/test/test_referer.rb
CHANGED
data/test/test_relative_links.rb
CHANGED
data/test/test_request.rb
CHANGED
data/test/test_response_code.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class ResponseCodeMechTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_eof_error_loop
|
@@ -42,10 +42,10 @@ class ResponseCodeMechTest < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_error
|
45
|
-
@agent =
|
45
|
+
@agent = Mechanize.new
|
46
46
|
begin
|
47
47
|
@agent.get("http://localhost/response_code?code=500")
|
48
|
-
rescue
|
48
|
+
rescue Mechanize::ResponseCodeError => err
|
49
49
|
assert_equal("500", err.response_code)
|
50
50
|
end
|
51
51
|
end
|
data/test/test_save_file.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class TestSaveFile < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_save_file
|
@@ -16,7 +16,7 @@ class TestSaveFile < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_save_file_default
|
19
|
-
page =
|
19
|
+
page = Mechanize::File.new(
|
20
20
|
URI.parse('http://localhost/test.html'),
|
21
21
|
{},
|
22
22
|
"hello"
|
@@ -33,7 +33,7 @@ class TestSaveFile < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_save_file_default_with_dots
|
36
|
-
page =
|
36
|
+
page = Mechanize::File.new(
|
37
37
|
URI.parse('http://localhost/../test.html'),
|
38
38
|
{},
|
39
39
|
"hello"
|
data/test/test_scheme.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
2
2
|
|
3
3
|
class SchemeTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@agent =
|
5
|
+
@agent = Mechanize.new
|
6
6
|
@agent.log = Class.new(Object) do
|
7
7
|
def method_missing(*args)
|
8
8
|
end
|
@@ -20,14 +20,14 @@ class SchemeTest < Test::Unit::TestCase
|
|
20
20
|
File.join(File.dirname(__FILE__), "htdocs", 'google.html'))
|
21
21
|
page = @agent.get("file://#{f}")
|
22
22
|
assert_equal(File.read(f), page.body)
|
23
|
-
assert_kind_of(
|
23
|
+
assert_kind_of(Mechanize::Page, page)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_file_scheme_supports_directories
|
27
27
|
f = File.expand_path(File.join(File.dirname(__FILE__), "htdocs"))
|
28
28
|
page = @agent.get("file://#{f}")
|
29
29
|
assert_equal(Dir[File.join(f, '*')].length, page.links.length)
|
30
|
-
assert_kind_of(
|
30
|
+
assert_kind_of(Mechanize::Page, page)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_click_file_link
|