mechanize 2.0 → 2.0.1

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.

Files changed (62) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -0
  3. data/CHANGELOG.rdoc +12 -1
  4. data/Manifest.txt +1 -0
  5. data/Rakefile +4 -2
  6. data/lib/mechanize.rb +23 -13
  7. data/lib/mechanize/cookie_jar.rb +13 -7
  8. data/test/helper.rb +1 -1
  9. data/test/test_cookies.rb +12 -12
  10. data/test/test_form_action.rb +1 -1
  11. data/test/test_form_as_hash.rb +5 -7
  12. data/test/test_form_button.rb +1 -1
  13. data/test/test_frames.rb +1 -1
  14. data/test/test_headers.rb +1 -1
  15. data/test/test_history.rb +1 -1
  16. data/test/test_history_added.rb +1 -1
  17. data/test/test_html_unscape_forms.rb +1 -1
  18. data/test/test_if_modified_since.rb +1 -1
  19. data/test/test_images.rb +1 -1
  20. data/test/test_mechanize.rb +45 -27
  21. data/test/test_mechanize_cookie.rb +6 -6
  22. data/test/test_mechanize_cookie_jar.rb +5 -4
  23. data/test/test_mechanize_file.rb +1 -1
  24. data/test/test_mechanize_file_request.rb +1 -1
  25. data/test/test_mechanize_file_response.rb +1 -1
  26. data/test/test_mechanize_form.rb +148 -233
  27. data/test/test_mechanize_form_check_box.rb +1 -1
  28. data/test/test_mechanize_form_encoding.rb +8 -6
  29. data/test/test_mechanize_form_field.rb +1 -1
  30. data/test/test_mechanize_form_image_button.rb +1 -1
  31. data/test/test_mechanize_form_textarea.rb +9 -3
  32. data/test/test_mechanize_http_agent.rb +2 -2
  33. data/test/test_mechanize_link.rb +8 -7
  34. data/test/test_mechanize_page_encoding.rb +1 -1
  35. data/test/test_mechanize_page_link.rb +5 -2
  36. data/test/test_mechanize_page_meta_refresh.rb +1 -1
  37. data/test/test_mechanize_redirect_not_get_or_head_error.rb +1 -1
  38. data/test/test_mechanize_subclass.rb +1 -1
  39. data/test/test_mechanize_util.rb +18 -18
  40. data/test/test_multi_select.rb +1 -1
  41. data/test/test_no_attributes.rb +4 -4
  42. data/test/test_option.rb +1 -1
  43. data/test/test_pluggable_parser.rb +11 -20
  44. data/test/test_post_form.rb +9 -13
  45. data/test/test_pretty_print.rb +1 -1
  46. data/test/test_radiobutton.rb +1 -1
  47. data/test/test_redirect_limit_reached.rb +1 -1
  48. data/test/test_referer.rb +1 -1
  49. data/test/test_relative_links.rb +2 -2
  50. data/test/test_request.rb +1 -1
  51. data/test/test_response_code.rb +1 -1
  52. data/test/test_robots.rb +18 -29
  53. data/test/test_save_file.rb +1 -1
  54. data/test/test_scheme.rb +3 -3
  55. data/test/test_select.rb +5 -2
  56. data/test/test_select_all.rb +1 -1
  57. data/test/test_select_none.rb +1 -1
  58. data/test/test_select_noopts.rb +5 -3
  59. data/test/test_set_fields.rb +1 -1
  60. data/test/test_ssl_server.rb +1 -1
  61. metadata +23 -5
  62. metadata.gz.sig +1 -2
data.tar.gz.sig CHANGED
Binary file
data/.autotest ADDED
@@ -0,0 +1,6 @@
1
+ require 'autotest/restart'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.testlib = 'minitest/autorun'
5
+ end
6
+
data/CHANGELOG.rdoc CHANGED
@@ -1,6 +1,17 @@
1
1
  = Mechanize CHANGELOG
2
2
 
3
- === 2.0.pre.2 / 2011-04-17
3
+ === 2.0.1 / 2011-06-28
4
+
5
+ Mechanize now uses minitest to avoid 1.9 vs 1.8 assertion availability in
6
+ test/unit
7
+
8
+ * Bug Fixes
9
+ * Restored Mechanize#set_proxy. Issue #117, #118, #119
10
+ * Mechanize::CookieJar#load now lazy-loads YAML. Issue #118
11
+ * Mechanize#keep_alive_time no longer crashes but does nothing as
12
+ net-http-persistent does not support HTTP/1.0 keep-alive extensions.
13
+
14
+ === 2.0 / 2011-06-27
4
15
 
5
16
  Mechanize is now under the MIT license
6
17
 
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ .autotest
1
2
  CHANGELOG.rdoc
2
3
  EXAMPLES.rdoc
3
4
  FAQ.rdoc
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
- Hoe.plugin :bundler
4
- Hoe.plugin :gemspec
3
+
5
4
  Hoe.plugin :git
5
+ Hoe.plugin :minitest
6
6
 
7
7
  Hoe.spec 'mechanize' do
8
8
  developer 'Eric Hodel', 'drbrain@segment7.net'
@@ -13,6 +13,8 @@ Hoe.spec 'mechanize' do
13
13
  self.history_file = 'CHANGELOG.rdoc'
14
14
  self.extra_rdoc_files += Dir['*.rdoc']
15
15
 
16
+ rdoc_locations << 'drbrain@rubyforge.org:/var/www/gforge-projects/mechanize/'
17
+
16
18
  self.extra_deps << ['nokogiri', '~> 1.4']
17
19
  self.extra_deps << ['net-http-persistent', '~> 1.8']
18
20
  self.extra_deps << ['net-http-digest_auth', '~> 1.1', '>= 1.1.1']
data/lib/mechanize.rb CHANGED
@@ -33,7 +33,7 @@ class Mechanize
33
33
 
34
34
  ##
35
35
  # The version of Mechanize you are using.
36
- VERSION = '2.0'
36
+ VERSION = '2.0.1'
37
37
 
38
38
  class Error < RuntimeError
39
39
  end
@@ -44,6 +44,14 @@ class Mechanize
44
44
  "#{RUBY_VERSION}dev#{RUBY_REVISION}"
45
45
  end
46
46
 
47
+ # HTTP/1.1 keep-alives are always active. This does nothing.
48
+ attr_accessor :keep_alive
49
+
50
+ # HTTP/1.0 keep-alive time. This is no longer supported by mechanize as it
51
+ # now uses net-http-persistent which only supports HTTP/1.1 persistent
52
+ # connections
53
+ attr_accessor :keep_alive_time
54
+
47
55
  ##
48
56
  # User Agent aliases
49
57
 
@@ -162,18 +170,6 @@ class Mechanize
162
170
  @agent.gzip_enabled = enabled
163
171
  end
164
172
 
165
- # HTTP/1.0 keep-alive time
166
- def keep_alive_time
167
- @agent.keep_alive_time
168
- end
169
-
170
- def keep_alive_time= keep_alive_time
171
- @agent.keep_alive_time = keep_alive_time
172
- end
173
-
174
- # HTTP/1.1 keep-alives are always active. This does nothing.
175
- attr_accessor :keep_alive
176
-
177
173
  def conditional_requests
178
174
  @agent.conditional_requests
179
175
  end
@@ -300,6 +296,7 @@ class Mechanize
300
296
  @pluggable_parser = PluggableParser.new
301
297
 
302
298
  @keep_alive = true
299
+ @keep_alive_time = 0
303
300
 
304
301
  # Proxy
305
302
  @proxy_addr = nil
@@ -578,6 +575,19 @@ class Mechanize
578
575
  end
579
576
  end
580
577
 
578
+ ##
579
+ # Sets the proxy +address+ at +port+ with an optional +user+ and +password+
580
+
581
+ def set_proxy address, port, user = nil, password = nil
582
+ @proxy_addr = address
583
+ @proxy_port = port
584
+ @proxy_user = user
585
+ @proxy_pass = password
586
+
587
+ @agent.set_proxy address, port, user, password
588
+ @agent.set_http
589
+ end
590
+
581
591
  # Runs given block, then resets the page history as it was before. self is
582
592
  # given as a parameter to the block. Returns the value of the block.
583
593
  def transact
@@ -83,12 +83,7 @@ class Mechanize::CookieJar
83
83
  open(file, 'w') { |f|
84
84
  case format
85
85
  when :yaml then
86
- begin
87
- require 'psych'
88
- rescue LoadError
89
- end
90
-
91
- require 'yaml'
86
+ load_yaml
92
87
 
93
88
  YAML.dump(jar.jar, f)
94
89
  when :cookiestxt then
@@ -110,7 +105,9 @@ class Mechanize::CookieJar
110
105
  @jar = open(file) { |f|
111
106
  case format
112
107
  when :yaml then
113
- YAML::load(f)
108
+ load_yaml
109
+
110
+ YAML.load(f)
114
111
  when :cookiestxt then
115
112
  load_cookiestxt(f)
116
113
  else
@@ -123,6 +120,15 @@ class Mechanize::CookieJar
123
120
  self
124
121
  end
125
122
 
123
+ def load_yaml # :nodoc:
124
+ begin
125
+ require 'psych'
126
+ rescue LoadError
127
+ end
128
+
129
+ require 'yaml'
130
+ end
131
+
126
132
  # Clear the cookie jar
127
133
  def clear!
128
134
  @jar = {}
data/test/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'test/unit'
2
1
  require 'rubygems'
2
+ require 'minitest/autorun'
3
3
  require 'mechanize'
4
4
  require 'webrick/httputils'
5
5
  require 'servlets'
data/test/test_cookies.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class CookiesMechTest < Test::Unit::TestCase
3
+ class CookiesMechTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
@@ -21,15 +21,15 @@ class CookiesMechTest < Test::Unit::TestCase
21
21
  page = @agent.get("http://localhost/many_cookies")
22
22
  page = @agent.get("http://localhost/send_cookies")
23
23
  assert_equal(3, page.links.length)
24
- assert_not_nil(page.links.find { |l| l.text == "name:Aaron" })
25
- assert_not_nil(page.links.find { |l| l.text == "no_expires:nope" })
24
+ assert(page.links.find { |l| l.text == "name:Aaron" })
25
+ assert(page.links.find { |l| l.text == "no_expires:nope" })
26
26
  end
27
27
 
28
28
  def test_no_space_cookies
29
29
  @agent.get("http://localhost/one_cookie_no_space")
30
30
  assert_equal(1, @agent.cookies.length)
31
31
  foo_cookie = @agent.cookies.find { |k| k.name == 'foo' }
32
- assert_not_nil(foo_cookie, 'Foo cookie was nil')
32
+ assert(foo_cookie, 'Foo cookie was nil')
33
33
  assert_equal('bar', foo_cookie.value)
34
34
  assert_equal('/', foo_cookie.path)
35
35
  assert_equal(true, Time.now < foo_cookie.expires)
@@ -40,7 +40,7 @@ class CookiesMechTest < Test::Unit::TestCase
40
40
  assert_equal(4, @agent.cookies.length)
41
41
 
42
42
  name_cookie = @agent.cookies.find { |k| k.name == "name" }
43
- assert_not_nil(name_cookie, "Name cookie was nil")
43
+
44
44
  assert_equal("Aaron", name_cookie.value)
45
45
  assert_equal("/", name_cookie.path)
46
46
  assert_equal(true, Time.now < name_cookie.expires)
@@ -49,18 +49,18 @@ class CookiesMechTest < Test::Unit::TestCase
49
49
  assert_nil(expired_cookie, "Expired cookie was not nil")
50
50
 
51
51
  no_exp_cookie = @agent.cookies.find { |k| k.name == "no_expires" }
52
- assert_not_nil(no_exp_cookie, "No expires cookie is nil")
52
+
53
53
  assert_equal("nope", no_exp_cookie.value)
54
54
  assert_equal("/", no_exp_cookie.path)
55
55
  assert_nil(no_exp_cookie.expires)
56
56
 
57
57
  path_cookie = @agent.cookies.find { |k| k.name == "a_path" }
58
- assert_not_nil(path_cookie, "Path cookie is nil")
58
+
59
59
  assert_equal("some_path", path_cookie.value)
60
60
  assert_equal(true, Time.now < path_cookie.expires)
61
61
 
62
62
  no_path_cookie = @agent.cookies.find { |k| k.name == "no_path" }
63
- assert_not_nil(no_path_cookie, "No path cookie is nil")
63
+
64
64
  assert_equal("no_path", no_path_cookie.value)
65
65
  assert_equal("/", no_path_cookie.path)
66
66
  assert_equal(true, Time.now < no_path_cookie.expires)
@@ -71,7 +71,7 @@ class CookiesMechTest < Test::Unit::TestCase
71
71
  assert_equal(4, @agent.cookies.length)
72
72
 
73
73
  name_cookie = @agent.cookies.find { |k| k.name == "name" }
74
- assert_not_nil(name_cookie, "Name cookie was nil")
74
+ assert(name_cookie, "Name cookie was nil")
75
75
  assert_equal("Aaron", name_cookie.value)
76
76
  assert_equal("/", name_cookie.path)
77
77
  assert_equal(true, Time.now < name_cookie.expires)
@@ -80,18 +80,18 @@ class CookiesMechTest < Test::Unit::TestCase
80
80
  assert_nil(expired_cookie, "Expired cookie was not nil")
81
81
 
82
82
  no_exp_cookie = @agent.cookies.find { |k| k.name == "no_expires" }
83
- assert_not_nil(no_exp_cookie, "No expires cookie is nil")
83
+ assert(no_exp_cookie, "No expires cookie is nil")
84
84
  assert_equal("nope", no_exp_cookie.value)
85
85
  assert_equal("/", no_exp_cookie.path)
86
86
  assert_nil(no_exp_cookie.expires)
87
87
 
88
88
  path_cookie = @agent.cookies.find { |k| k.name == "a_path" }
89
- assert_not_nil(path_cookie, "Path cookie is nil")
89
+ assert(path_cookie, "Path cookie is nil")
90
90
  assert_equal("some_path", path_cookie.value)
91
91
  assert_equal(true, Time.now < path_cookie.expires)
92
92
 
93
93
  no_path_cookie = @agent.cookies.find { |k| k.name == "no_path" }
94
- assert_not_nil(no_path_cookie, "No path cookie is nil")
94
+ assert(no_path_cookie, "No path cookie is nil")
95
95
  assert_equal("no_path", no_path_cookie.value)
96
96
  assert_equal("/", no_path_cookie.path)
97
97
  assert_equal(true, Time.now < no_path_cookie.expires)
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestFormAction < Test::Unit::TestCase
3
+ class TestFormAction < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  @page = @agent.get("http://localhost/tc_form_action.html")
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestFormHash < Test::Unit::TestCase
3
+ class TestFormHash < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  @page = @agent.get('http://localhost/form_multival.html')
@@ -9,31 +9,28 @@ class TestFormHash < Test::Unit::TestCase
9
9
  def test_form_hash
10
10
  form = @page.form_with(:name => 'post_form')
11
11
 
12
- assert_not_nil(form)
13
12
  field_length = form.fields.length
14
13
  assert_nil(form['intarweb'])
15
14
  form['intarweb'] = 'Aaron'
16
15
 
17
- assert_not_nil(form['intarweb'])
16
+ assert form['intarweb']
18
17
  assert_equal(field_length + 1, form.fields.length)
19
18
  end
20
19
 
21
20
  def test_add_field_via_hash
22
21
  form = @page.form_with(:name => 'post_form')
23
22
 
24
- assert_not_nil(form)
25
23
  field_length = form.fields.length
26
24
  assert_nil(form['intarweb'])
27
25
  form['intarweb'] = 'Aaron'
28
26
 
29
- assert_not_nil(form['intarweb'])
27
+ assert form['intarweb']
30
28
  assert_equal(field_length + 1, form.fields.length)
31
29
  end
32
30
 
33
31
  def test_fields_as_hash
34
32
  form = @page.form_with(:name => 'post_form')
35
33
 
36
- assert_not_nil(form)
37
34
  assert_equal(2, form.fields_with(:name => 'first').length)
38
35
 
39
36
  form['first'] = 'Aaron'
@@ -45,12 +42,13 @@ class TestFormHash < Test::Unit::TestCase
45
42
  @page = @agent.get('http://localhost/empty_form.html')
46
43
  form = @page.forms.first
47
44
 
48
- assert_not_nil(form)
49
45
  assert(!form.has_field?('name'))
50
46
  assert(!form.has_value?('Aaron'))
51
47
  assert_equal(0, form.keys.length)
52
48
  assert_equal(0, form.values.length)
49
+
53
50
  form['name'] = 'Aaron'
51
+
54
52
  assert(form.has_field?('name'))
55
53
  assert(form.has_value?('Aaron'))
56
54
  assert_equal(1, form.keys.length)
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestFormButtons < Test::Unit::TestCase
3
+ class TestFormButtons < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
data/test/test_frames.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class FramesMechTest < Test::Unit::TestCase
3
+ class FramesMechTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
data/test/test_headers.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestHeaders < Test::Unit::TestCase
3
+ class TestHeaders < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @headers = Mechanize::Headers.new
6
6
  @headers['content-type'] = 'text/html'
data/test/test_history.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestHistory < Test::Unit::TestCase
3
+ class TestHistory < MiniTest::Unit::TestCase
4
4
 
5
5
  Node = Struct.new :href, :inner_text
6
6
 
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class HistoryAddedTest < Test::Unit::TestCase
3
+ class HistoryAddedTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestCheckBoxes < Test::Unit::TestCase
3
+ class TestCheckBoxes < MiniTest::Unit::TestCase
4
4
  def test_field
5
5
  f = Mechanize::Form::Field.new({'name' => 'a&amp;b'}, 'a&amp;b')
6
6
  assert_equal('a&b', f.name)
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class TestIfModifiedSince < Test::Unit::TestCase
3
+ class TestIfModifiedSince < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
data/test/test_images.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class ImagesMechTest < Test::Unit::TestCase
3
+ class ImagesMechTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @agent = Mechanize.new
6
6
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'helper'
4
4
 
5
- class TestMechanize < Test::Unit::TestCase
5
+ class TestMechanize < MiniTest::Unit::TestCase
6
6
 
7
7
  KEY = OpenSSL::PKey::RSA.new 512
8
8
  name = OpenSSL::X509::Name.parse 'CN=nobody/DC=example'
@@ -91,32 +91,31 @@ class TestMechanize < Test::Unit::TestCase
91
91
  @mech.user_agent_alias = 'Mac Safari'
92
92
  page = @mech.get("http://localhost/frame_test.html")
93
93
  link = page.link_with(:text => "Form Test")
94
- assert_not_nil(link)
94
+
95
95
  page = @mech.click(link)
96
+
96
97
  assert_equal("http://localhost/form_test.html",
97
- @mech.history.last.uri.to_s)
98
+ @mech.history.last.uri.to_s)
98
99
  end
99
100
 
100
101
  def test_click_frame_hpricot_style
101
102
  page = @mech.get("http://localhost/frame_test.html")
102
-
103
103
  link = (page/"//frame[@name='frame2']").first
104
- assert_not_nil(link)
104
+
105
105
  page = @mech.click(link)
106
+
106
107
  assert_equal("http://localhost/form_test.html",
107
- @mech.history.last.uri.to_s)
108
+ @mech.history.last.uri.to_s)
108
109
  end
109
110
 
110
111
  def test_click_hpricot_style # HACK move to test_divide in Page
111
112
  page = @mech.get("http://localhost/frame_test.html")
112
-
113
113
  link = (page/"//a[@class='bar']").first
114
- assert_not_nil(link)
115
114
 
116
115
  page = @mech.click(link)
117
116
 
118
117
  assert_equal("http://localhost/form_test.html",
119
- @mech.history.last.uri.to_s)
118
+ @mech.history.last.uri.to_s)
120
119
  end
121
120
 
122
121
  def test_click_link
@@ -216,8 +215,8 @@ class TestMechanize < Test::Unit::TestCase
216
215
  end
217
216
 
218
217
  def test_get_bad_url
219
- assert_raise ArgumentError do
220
- @mech.get('/foo.html')
218
+ assert_raises ArgumentError do
219
+ @mech.get '/foo.html'
221
220
  end
222
221
  end
223
222
 
@@ -383,8 +382,9 @@ class TestMechanize < Test::Unit::TestCase
383
382
  def test_get_kcode
384
383
  $KCODE = 'u'
385
384
  page = @mech.get("http://localhost/?a=#{[0xd6].pack('U')}")
386
- assert_not_nil(page)
385
+
387
386
  assert_equal('http://localhost/?a=%D6', page.uri.to_s)
387
+
388
388
  $KCODE = 'NONE'
389
389
  end unless RUBY_VERSION >= '1.9.0'
390
390
 
@@ -426,9 +426,10 @@ class TestMechanize < Test::Unit::TestCase
426
426
  end
427
427
 
428
428
  def test_get_referer_file
429
- assert_nothing_raised do
430
- @mech.get('http://localhost', [], Mechanize::File.new(URI.parse('http://tenderlovemaking.com/crossdomain.xml')))
431
- end
429
+ uri = URI.parse 'http://tenderlovemaking.com/crossdomain.xml'
430
+ file = Mechanize::File.new uri
431
+
432
+ @mech.get('http://localhost', [], file)
432
433
 
433
434
  # HACK no assertion of behavior
434
435
  end
@@ -448,9 +449,9 @@ class TestMechanize < Test::Unit::TestCase
448
449
  end
449
450
 
450
451
  def test_get_scheme_unsupported
451
- assert_raise(Mechanize::UnsupportedSchemeError) {
452
+ assert_raises Mechanize::UnsupportedSchemeError do
452
453
  @mech.get('ftp://server.com/foo.html')
453
- }
454
+ end
454
455
  end
455
456
 
456
457
  def test_get_space
@@ -470,15 +471,11 @@ class TestMechanize < Test::Unit::TestCase
470
471
  end
471
472
 
472
473
  def test_get_weird
473
- assert_nothing_raised {
474
- @mech.get('http://localhost/?action=bing&bang=boom=1|a=|b=|c=')
475
- }
476
- assert_nothing_raised {
477
- @mech.get('http://localhost/?a=b&#038;b=c&#038;c=d')
478
- }
479
- assert_nothing_raised {
480
- @mech.get("http://localhost/?a=#{[0xd6].pack('U')}")
481
- }
474
+ @mech.get('http://localhost/?action=bing&bang=boom=1|a=|b=|c=')
475
+ @mech.get('http://localhost/?a=b&#038;b=c&#038;c=d')
476
+ @mech.get("http://localhost/?a=#{[0xd6].pack('U')}")
477
+
478
+ # HACK no assertion of behavior
482
479
  end
483
480
 
484
481
  def test_get_yield
@@ -550,6 +547,14 @@ class TestMechanize < Test::Unit::TestCase
550
547
  }
551
548
  end
552
549
 
550
+ def test_keep_alive_time
551
+ assert_equal 0, @mech.keep_alive_time
552
+
553
+ @mech.keep_alive_time = 1
554
+
555
+ assert_equal 1, @mech.keep_alive_time
556
+ end
557
+
553
558
  def test_max_history_equals
554
559
  @mech.max_history = 10
555
560
  0.upto(10) do |i|
@@ -627,9 +632,22 @@ class TestMechanize < Test::Unit::TestCase
627
632
  assert_equal 5, @mech.read_timeout
628
633
  end
629
634
 
635
+ def test_set_proxy
636
+ http = @mech.agent.http
637
+
638
+ @mech.set_proxy 'localhost', 8080, 'user', 'pass'
639
+
640
+ assert_equal 'localhost', @mech.proxy_addr
641
+ assert_equal 8080, @mech.proxy_port
642
+ assert_equal 'user', @mech.proxy_user
643
+ assert_equal 'pass', @mech.proxy_pass
644
+
645
+ refute_same http, @mech.agent.http
646
+ end
647
+
630
648
  def test_submit_bad_form_method
631
649
  page = @mech.get("http://localhost/bad_form_test.html")
632
- assert_raise ArgumentError do
650
+ assert_raises ArgumentError do
633
651
  @mech.submit(page.forms.first)
634
652
  end
635
653
  end