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.
Files changed (165) hide show
  1. data/Manifest.txt +55 -48
  2. data/Rakefile +12 -22
  3. data/lib/mechanize.rb +618 -4
  4. data/lib/mechanize/chain.rb +33 -0
  5. data/lib/mechanize/chain/auth_headers.rb +78 -0
  6. data/lib/mechanize/chain/body_decoding_handler.rb +46 -0
  7. data/lib/mechanize/chain/connection_resolver.rb +76 -0
  8. data/lib/mechanize/chain/custom_headers.rb +21 -0
  9. data/lib/{www/mechanize → mechanize}/chain/handler.rb +1 -1
  10. data/lib/mechanize/chain/header_resolver.rb +51 -0
  11. data/lib/mechanize/chain/parameter_resolver.rb +22 -0
  12. data/lib/{www/mechanize → mechanize}/chain/post_connect_hook.rb +0 -0
  13. data/lib/mechanize/chain/pre_connect_hook.rb +20 -0
  14. data/lib/mechanize/chain/request_resolver.rb +30 -0
  15. data/lib/mechanize/chain/response_body_parser.rb +38 -0
  16. data/lib/mechanize/chain/response_header_handler.rb +48 -0
  17. data/lib/mechanize/chain/response_reader.rb +39 -0
  18. data/lib/mechanize/chain/ssl_resolver.rb +40 -0
  19. data/lib/mechanize/chain/uri_resolver.rb +75 -0
  20. data/lib/mechanize/content_type_error.rb +14 -0
  21. data/lib/mechanize/cookie.rb +70 -0
  22. data/lib/mechanize/cookie_jar.rb +188 -0
  23. data/lib/mechanize/file.rb +71 -0
  24. data/lib/mechanize/file_response.rb +60 -0
  25. data/lib/mechanize/file_saver.rb +37 -0
  26. data/lib/mechanize/form.rb +378 -0
  27. data/lib/mechanize/form/button.rb +9 -0
  28. data/lib/mechanize/form/check_box.rb +11 -0
  29. data/lib/mechanize/form/field.rb +30 -0
  30. data/lib/mechanize/form/file_upload.rb +22 -0
  31. data/lib/mechanize/form/image_button.rb +21 -0
  32. data/lib/mechanize/form/multi_select_list.rb +67 -0
  33. data/lib/mechanize/form/option.rb +49 -0
  34. data/lib/mechanize/form/radio_button.rb +49 -0
  35. data/lib/mechanize/form/select_list.rb +43 -0
  36. data/lib/mechanize/headers.rb +11 -0
  37. data/lib/mechanize/history.rb +65 -0
  38. data/lib/mechanize/inspect.rb +88 -0
  39. data/lib/{www/mechanize → mechanize}/monkey_patch.rb +4 -6
  40. data/lib/mechanize/page.rb +206 -0
  41. data/lib/mechanize/page/base.rb +8 -0
  42. data/lib/mechanize/page/frame.rb +20 -0
  43. data/lib/mechanize/page/image.rb +26 -0
  44. data/lib/mechanize/page/label.rb +20 -0
  45. data/lib/mechanize/page/link.rb +48 -0
  46. data/lib/mechanize/page/meta.rb +50 -0
  47. data/lib/mechanize/pluggable_parsers.rb +101 -0
  48. data/lib/mechanize/redirect_limit_reached_error.rb +16 -0
  49. data/lib/mechanize/redirect_not_get_or_head_error.rb +18 -0
  50. data/lib/mechanize/response_code_error.rb +22 -0
  51. data/lib/mechanize/unsupported_scheme_error.rb +8 -0
  52. data/lib/mechanize/util.rb +67 -0
  53. data/mechanize.gemspec +8 -8
  54. data/test/chain/test_argument_validator.rb +2 -2
  55. data/test/chain/test_auth_headers.rb +2 -2
  56. data/test/chain/test_custom_headers.rb +2 -2
  57. data/test/chain/test_header_resolver.rb +3 -3
  58. data/test/chain/test_parameter_resolver.rb +4 -4
  59. data/test/chain/test_request_resolver.rb +4 -4
  60. data/test/chain/test_response_reader.rb +3 -3
  61. data/test/helper.rb +1 -1
  62. data/test/htdocs/tc_bad_charset.html +9 -0
  63. data/test/htdocs/tc_charset.html +6 -0
  64. data/test/htdocs/test_bad_encoding.html +52 -0
  65. data/test/test_authenticate.rb +3 -3
  66. data/test/test_bad_links.rb +1 -1
  67. data/test/test_blank_form.rb +1 -1
  68. data/test/test_checkboxes.rb +1 -1
  69. data/test/test_content_type.rb +2 -2
  70. data/test/test_cookie_class.rb +12 -12
  71. data/test/test_cookie_jar.rb +13 -13
  72. data/test/test_cookies.rb +1 -1
  73. data/test/test_encoded_links.rb +1 -1
  74. data/test/test_errors.rb +2 -2
  75. data/test/test_follow_meta.rb +3 -3
  76. data/test/test_form_action.rb +1 -1
  77. data/test/test_form_as_hash.rb +1 -1
  78. data/test/test_form_button.rb +2 -2
  79. data/test/test_form_no_inputname.rb +1 -1
  80. data/test/test_forms.rb +1 -1
  81. data/test/test_frames.rb +1 -1
  82. data/test/test_get_headers.rb +1 -1
  83. data/test/test_gzipping.rb +2 -2
  84. data/test/test_hash_api.rb +1 -1
  85. data/test/test_history.rb +7 -7
  86. data/test/test_history_added.rb +1 -1
  87. data/test/test_html_unscape_forms.rb +7 -7
  88. data/test/test_if_modified_since.rb +1 -1
  89. data/test/test_keep_alive.rb +1 -1
  90. data/test/test_links.rb +2 -2
  91. data/test/test_mech.rb +2 -2
  92. data/test/test_mechanize_file.rb +7 -7
  93. data/test/test_meta.rb +2 -2
  94. data/test/test_multi_select.rb +1 -1
  95. data/test/test_no_attributes.rb +1 -1
  96. data/test/test_option.rb +1 -1
  97. data/test/test_page.rb +3 -3
  98. data/test/test_pluggable_parser.rb +14 -14
  99. data/test/test_post_form.rb +1 -1
  100. data/test/test_pretty_print.rb +2 -2
  101. data/test/test_radiobutton.rb +1 -1
  102. data/test/test_redirect_limit_reached.rb +1 -3
  103. data/test/test_redirect_verb_handling.rb +1 -3
  104. data/test/test_referer.rb +1 -1
  105. data/test/test_relative_links.rb +1 -1
  106. data/test/test_request.rb +1 -1
  107. data/test/test_response_code.rb +3 -3
  108. data/test/test_save_file.rb +3 -3
  109. data/test/test_scheme.rb +3 -3
  110. data/test/test_select.rb +2 -2
  111. data/test/test_select_all.rb +1 -1
  112. data/test/test_select_none.rb +1 -1
  113. data/test/test_select_noopts.rb +1 -1
  114. data/test/test_set_fields.rb +1 -1
  115. data/test/test_ssl_server.rb +1 -1
  116. data/test/test_subclass.rb +1 -1
  117. data/test/test_textarea.rb +1 -1
  118. data/test/test_upload.rb +1 -1
  119. data/test/test_verbs.rb +1 -1
  120. metadata +61 -56
  121. data/lib/www/mechanize.rb +0 -619
  122. data/lib/www/mechanize/chain.rb +0 -34
  123. data/lib/www/mechanize/chain/auth_headers.rb +0 -80
  124. data/lib/www/mechanize/chain/body_decoding_handler.rb +0 -48
  125. data/lib/www/mechanize/chain/connection_resolver.rb +0 -78
  126. data/lib/www/mechanize/chain/custom_headers.rb +0 -23
  127. data/lib/www/mechanize/chain/header_resolver.rb +0 -53
  128. data/lib/www/mechanize/chain/parameter_resolver.rb +0 -24
  129. data/lib/www/mechanize/chain/pre_connect_hook.rb +0 -22
  130. data/lib/www/mechanize/chain/request_resolver.rb +0 -32
  131. data/lib/www/mechanize/chain/response_body_parser.rb +0 -40
  132. data/lib/www/mechanize/chain/response_header_handler.rb +0 -50
  133. data/lib/www/mechanize/chain/response_reader.rb +0 -41
  134. data/lib/www/mechanize/chain/ssl_resolver.rb +0 -42
  135. data/lib/www/mechanize/chain/uri_resolver.rb +0 -77
  136. data/lib/www/mechanize/content_type_error.rb +0 -16
  137. data/lib/www/mechanize/cookie.rb +0 -72
  138. data/lib/www/mechanize/cookie_jar.rb +0 -191
  139. data/lib/www/mechanize/file.rb +0 -73
  140. data/lib/www/mechanize/file_response.rb +0 -62
  141. data/lib/www/mechanize/file_saver.rb +0 -39
  142. data/lib/www/mechanize/form.rb +0 -360
  143. data/lib/www/mechanize/form/button.rb +0 -8
  144. data/lib/www/mechanize/form/check_box.rb +0 -13
  145. data/lib/www/mechanize/form/field.rb +0 -28
  146. data/lib/www/mechanize/form/file_upload.rb +0 -24
  147. data/lib/www/mechanize/form/image_button.rb +0 -23
  148. data/lib/www/mechanize/form/multi_select_list.rb +0 -69
  149. data/lib/www/mechanize/form/option.rb +0 -51
  150. data/lib/www/mechanize/form/radio_button.rb +0 -38
  151. data/lib/www/mechanize/form/select_list.rb +0 -45
  152. data/lib/www/mechanize/headers.rb +0 -12
  153. data/lib/www/mechanize/history.rb +0 -67
  154. data/lib/www/mechanize/inspect.rb +0 -90
  155. data/lib/www/mechanize/page.rb +0 -181
  156. data/lib/www/mechanize/page/base.rb +0 -10
  157. data/lib/www/mechanize/page/frame.rb +0 -22
  158. data/lib/www/mechanize/page/link.rb +0 -50
  159. data/lib/www/mechanize/page/meta.rb +0 -51
  160. data/lib/www/mechanize/pluggable_parsers.rb +0 -103
  161. data/lib/www/mechanize/redirect_limit_reached_error.rb +0 -18
  162. data/lib/www/mechanize/redirect_not_get_or_head_error.rb +0 -20
  163. data/lib/www/mechanize/response_code_error.rb +0 -25
  164. data/lib/www/mechanize/unsupported_scheme_error.rb +0 -10
  165. data/lib/www/mechanize/util.rb +0 -76
@@ -51,7 +51,7 @@ class CookieClassTest < Test::Unit::TestCase
51
51
  dates.each do |date|
52
52
  cookie = "PREF=1; expires=#{date}"
53
53
  silently do
54
- WWW::Mechanize::Cookie.parse(url, cookie) { |c|
54
+ Mechanize::Cookie.parse(url, cookie) { |c|
55
55
  assert c.expires, "Tried parsing: #{date}"
56
56
  assert_equal(true, c.expires < yesterday)
57
57
  }
@@ -62,7 +62,7 @@ class CookieClassTest < Test::Unit::TestCase
62
62
  def test_parse_weird_cookie
63
63
  cookie = 'n/a, ASPSESSIONIDCSRRQDQR=FBLDGHPBNDJCPCGNCPAENELB; path=/'
64
64
  url = URI.parse('http://www.searchinnovation.com/')
65
- WWW::Mechanize::Cookie.parse(url, cookie) { |c|
65
+ Mechanize::Cookie.parse(url, cookie) { |c|
66
66
  assert_equal('ASPSESSIONIDCSRRQDQR', c.name)
67
67
  assert_equal('FBLDGHPBNDJCPCGNCPAENELB', c.value)
68
68
  }
@@ -71,7 +71,7 @@ class CookieClassTest < Test::Unit::TestCase
71
71
  def test_double_semicolon
72
72
  double_semi = 'WSIDC=WEST;; domain=.williams-sonoma.com; path=/'
73
73
  url = URI.parse('http://williams-sonoma.com/')
74
- WWW::Mechanize::Cookie.parse(url, double_semi) { |cookie|
74
+ Mechanize::Cookie.parse(url, double_semi) { |cookie|
75
75
  assert_equal('WSIDC', cookie.name)
76
76
  assert_equal('WEST', cookie.value)
77
77
  }
@@ -80,7 +80,7 @@ class CookieClassTest < Test::Unit::TestCase
80
80
  def test_parse_bad_version
81
81
  bad_cookie = 'PRETANET=TGIAqbFXtt; Name=/PRETANET; Path=/; Version=1.2; Content-type=text/html; Domain=192.168.6.196; expires=Friday, 13-November-2026 23:01:46 GMT;'
82
82
  url = URI.parse('http://localhost/')
83
- WWW::Mechanize::Cookie.parse(url, bad_cookie) { |cookie|
83
+ Mechanize::Cookie.parse(url, bad_cookie) { |cookie|
84
84
  assert_nil(cookie.version)
85
85
  }
86
86
  end
@@ -88,7 +88,7 @@ class CookieClassTest < Test::Unit::TestCase
88
88
  def test_parse_bad_max_age
89
89
  bad_cookie = 'PRETANET=TGIAqbFXtt; Name=/PRETANET; Path=/; Max-Age=1.2; Content-type=text/html; Domain=192.168.6.196; expires=Friday, 13-November-2026 23:01:46 GMT;'
90
90
  url = URI.parse('http://localhost/')
91
- WWW::Mechanize::Cookie.parse(url, bad_cookie) { |cookie|
91
+ Mechanize::Cookie.parse(url, bad_cookie) { |cookie|
92
92
  assert_nil(cookie.max_age)
93
93
  }
94
94
  end
@@ -103,7 +103,7 @@ class CookieClassTest < Test::Unit::TestCase
103
103
  silently do
104
104
  dates.each do |date|
105
105
  cookie = "PREF=1; expires=#{date}"
106
- WWW::Mechanize::Cookie.parse(url, cookie) { |c|
106
+ Mechanize::Cookie.parse(url, cookie) { |c|
107
107
  assert_equal(true, c.expires.nil?)
108
108
  }
109
109
  end
@@ -131,7 +131,7 @@ class CookieClassTest < Test::Unit::TestCase
131
131
  end
132
132
  end
133
133
  cookie = nil
134
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
134
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
135
135
  assert_not_nil(cookie)
136
136
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
137
137
  assert_equal('/', cookie.path)
@@ -167,7 +167,7 @@ class CookieClassTest < Test::Unit::TestCase
167
167
  end
168
168
  end
169
169
  cookie = nil
170
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
170
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
171
171
  assert_not_nil(cookie)
172
172
  assert_equal('12345%7D=', cookie.to_s)
173
173
  assert_equal('', cookie.value)
@@ -206,7 +206,7 @@ class CookieClassTest < Test::Unit::TestCase
206
206
  end
207
207
  end
208
208
  cookie = nil
209
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
209
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
210
210
  assert_not_nil(cookie)
211
211
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
212
212
  assert_equal('rubyforge.org', cookie.domain)
@@ -244,7 +244,7 @@ class CookieClassTest < Test::Unit::TestCase
244
244
  end
245
245
  end
246
246
  cookie = nil
247
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
247
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
248
248
  assert_not_nil(cookie)
249
249
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
250
250
  assert_equal('rubyforge.org', cookie.domain)
@@ -283,7 +283,7 @@ class CookieClassTest < Test::Unit::TestCase
283
283
  end
284
284
  end
285
285
  cookie = nil
286
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
286
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
287
287
  assert_not_nil(cookie)
288
288
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
289
289
  assert_equal('/', cookie.path)
@@ -320,7 +320,7 @@ class CookieClassTest < Test::Unit::TestCase
320
320
  end
321
321
  end
322
322
  cookie = nil
323
- WWW::Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
323
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie }
324
324
  assert_not_nil(cookie)
325
325
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
326
326
  assert_equal('/', cookie.path)
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class CookieJarTest < Test::Unit::TestCase
4
4
  def cookie_from_hash(hash)
5
- c = WWW::Mechanize::Cookie.new(hash[:name], hash[:value])
5
+ c = Mechanize::Cookie.new(hash[:name], hash[:value])
6
6
  hash.each { |k,v|
7
7
  next if k == :name || k == :value
8
8
  c.send("#{k}=", v)
@@ -20,7 +20,7 @@ class CookieJarTest < Test::Unit::TestCase
20
20
 
21
21
  url = URI.parse('http://rubyforge.org/')
22
22
 
23
- jar = WWW::Mechanize::CookieJar.new
23
+ jar = Mechanize::CookieJar.new
24
24
  cookie = cookie_from_hash(values)
25
25
  jar.add(url, cookie)
26
26
  jar.add(url, cookie_from_hash(values.merge(:path => '/onetwo')))
@@ -38,7 +38,7 @@ class CookieJarTest < Test::Unit::TestCase
38
38
  }
39
39
  url = URI.parse('http://rubyforge.org/')
40
40
 
41
- jar = WWW::Mechanize::CookieJar.new
41
+ jar = Mechanize::CookieJar.new
42
42
  assert_equal(0, jar.cookies(url).length)
43
43
 
44
44
  # Add one cookie with an expiration date in the future
@@ -65,7 +65,7 @@ class CookieJarTest < Test::Unit::TestCase
65
65
  }
66
66
  url = URI.parse('http://rubyforge.org/')
67
67
 
68
- jar = WWW::Mechanize::CookieJar.new
68
+ jar = Mechanize::CookieJar.new
69
69
  assert_equal(0, jar.cookies(url).length)
70
70
 
71
71
  # Add one cookie with an expiration date in the future
@@ -92,7 +92,7 @@ class CookieJarTest < Test::Unit::TestCase
92
92
  }
93
93
  url = URI.parse('http://rubyforge.org/')
94
94
 
95
- jar = WWW::Mechanize::CookieJar.new
95
+ jar = Mechanize::CookieJar.new
96
96
  assert_equal(0, jar.cookies(url).length)
97
97
 
98
98
  # Add one cookie with an expiration date in the future
@@ -120,7 +120,7 @@ class CookieJarTest < Test::Unit::TestCase
120
120
  }
121
121
  url = URI.parse('http://rubyforge.org/')
122
122
 
123
- jar = WWW::Mechanize::CookieJar.new
123
+ jar = Mechanize::CookieJar.new
124
124
  assert_equal(0, jar.cookies(url).length)
125
125
 
126
126
  # Add one cookie with an expiration date in the future
@@ -148,7 +148,7 @@ class CookieJarTest < Test::Unit::TestCase
148
148
  }
149
149
  url = URI.parse('http://rubyforge.org/')
150
150
 
151
- jar = WWW::Mechanize::CookieJar.new
151
+ jar = Mechanize::CookieJar.new
152
152
  assert_equal(0, jar.cookies(url).length)
153
153
 
154
154
  # Add one cookie with an expiration date in the future
@@ -171,7 +171,7 @@ class CookieJarTest < Test::Unit::TestCase
171
171
  }
172
172
  url = URI.parse('http://rubyforge.org/')
173
173
 
174
- jar = WWW::Mechanize::CookieJar.new
174
+ jar = Mechanize::CookieJar.new
175
175
  assert_equal(0, jar.cookies(url).length)
176
176
 
177
177
  # Add one cookie with an expiration date in the future
@@ -198,7 +198,7 @@ class CookieJarTest < Test::Unit::TestCase
198
198
  }
199
199
  url = URI.parse('http://rubyforge.org/')
200
200
 
201
- jar = WWW::Mechanize::CookieJar.new
201
+ jar = Mechanize::CookieJar.new
202
202
  assert_equal(0, jar.cookies(url).length)
203
203
 
204
204
  # Add one cookie with an expiration date in the future
@@ -232,7 +232,7 @@ class CookieJarTest < Test::Unit::TestCase
232
232
  }
233
233
  url = URI.parse('http://rubyforge.org/')
234
234
 
235
- jar = WWW::Mechanize::CookieJar.new
235
+ jar = Mechanize::CookieJar.new
236
236
  assert_equal(0, jar.cookies(url).length)
237
237
 
238
238
  # Add one cookie with an expiration date in the future
@@ -276,7 +276,7 @@ class CookieJarTest < Test::Unit::TestCase
276
276
  }
277
277
  url = URI.parse('http://rubyforge.org/login')
278
278
 
279
- jar = WWW::Mechanize::CookieJar.new
279
+ jar = Mechanize::CookieJar.new
280
280
  assert_equal(0, jar.cookies(url).length)
281
281
 
282
282
  # Add one cookie with an expiration date in the future
@@ -312,7 +312,7 @@ class CookieJarTest < Test::Unit::TestCase
312
312
  }
313
313
  url = URI.parse('http://rubyforge.org/')
314
314
 
315
- jar = WWW::Mechanize::CookieJar.new
315
+ jar = Mechanize::CookieJar.new
316
316
  assert_equal(0, jar.cookies(url).length)
317
317
 
318
318
  # Add one cookie with an expiration date in the future
@@ -347,7 +347,7 @@ class CookieJarTest < Test::Unit::TestCase
347
347
  }
348
348
  url = URI.parse('https://rubyforge.org/login')
349
349
 
350
- jar = WWW::Mechanize::CookieJar.new
350
+ jar = Mechanize::CookieJar.new
351
351
  assert_equal(0, jar.cookies(url).length)
352
352
 
353
353
  cookie = cookie_from_hash(values)
data/test/test_cookies.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class CookiesMechTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_meta_tag_cookies
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestEncodedLinks < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get("http://localhost/tc_encoded_links.html")
7
7
  end
8
8
 
data/test/test_errors.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class MechErrorsTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_bad_form_method
@@ -42,7 +42,7 @@ class MechErrorsTest < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_unsupported_scheme
45
- assert_raise(WWW::Mechanize::UnsupportedSchemeError) {
45
+ assert_raise(Mechanize::UnsupportedSchemeError) {
46
46
  @agent.get('ftp://server.com/foo.html')
47
47
  }
48
48
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
2
 
3
3
  class FollowMetaTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_dont_follow_meta_by_default
@@ -71,10 +71,10 @@ class FollowMetaTest < Test::Unit::TestCase
71
71
 
72
72
  def test_infinite_refresh_throws_exception
73
73
  @agent.follow_meta_refresh = true
74
- assert_raises(WWW::Mechanize::RedirectLimitReachedError) {
74
+ assert_raises(Mechanize::RedirectLimitReachedError) {
75
75
  begin
76
76
  @agent.get('http://localhost/infinite_refresh')
77
- rescue WWW::Mechanize::RedirectLimitReachedError => ex
77
+ rescue Mechanize::RedirectLimitReachedError => ex
78
78
  raise ex
79
79
  end
80
80
  }
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestFormAction < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get("http://localhost/tc_form_action.html")
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestFormHash < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get('http://localhost/form_multival.html')
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestFormButtons < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_submit_input_tag
@@ -22,7 +22,7 @@ class TestFormButtons < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  def assert_form_contains_button(button)
25
- page = WWW::Mechanize::Page.new(nil, html_response, html(button), 200, @agent)
25
+ page = Mechanize::Page.new(nil, html_response, html(button), 200, @agent)
26
26
  assert_equal(1, page.forms.length)
27
27
  assert_equal(1, page.forms.first.buttons.length)
28
28
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class FormNoInputNameTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get('http://localhost/form_no_input_name.html')
7
7
  end
8
8
 
data/test/test_forms.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class FormsMechTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_no_form_action
data/test/test_frames.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class FramesMechTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_frames
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestGetHeaders < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_bad_header_symbol
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestGzip < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_request_empty_gzip
@@ -16,7 +16,7 @@ class TestGzip < Test::Unit::TestCase
16
16
  assert_nothing_raised do
17
17
  page = @agent.get("http://localhost/gzip?file=index.html")
18
18
  end
19
- assert_kind_of(WWW::Mechanize::Page, page)
19
+ assert_kind_of(Mechanize::Page, page)
20
20
  assert_match('Hello World', page.body)
21
21
  end
22
22
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestHashApi < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_title
data/test/test_history.rb CHANGED
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestHistory < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
6
- @history = WWW::Mechanize::History.new
5
+ @agent = Mechanize.new
6
+ @history = Mechanize::History.new
7
7
  end
8
8
 
9
9
  def test_push
@@ -72,7 +72,7 @@ class TestHistory < Test::Unit::TestCase
72
72
  end
73
73
 
74
74
  def test_max_size
75
- @history = WWW::Mechanize::History.new(10)
75
+ @history = Mechanize::History.new(10)
76
76
  1.upto(20) do |i|
77
77
  page = @agent.get('http://localhost/index.html')
78
78
  @history.push page
@@ -110,11 +110,11 @@ class TestHistory < Test::Unit::TestCase
110
110
  page = @agent.get('http://localhost')
111
111
 
112
112
  node = Struct.new(:href, :inner_text).new('http://localhost/', 'blah')
113
- link = WWW::Mechanize::Page::Link.new(node, nil, nil)
113
+ link = Mechanize::Page::Link.new(node, nil, nil)
114
114
  assert(@agent.visited?(link))
115
115
 
116
116
  node = Struct.new(:href, :inner_text).new('http://localhost', 'blah')
117
- link = WWW::Mechanize::Page::Link.new(node, nil, nil)
117
+ link = Mechanize::Page::Link.new(node, nil, nil)
118
118
  assert(@agent.visited?(link))
119
119
  end
120
120
 
@@ -122,11 +122,11 @@ class TestHistory < Test::Unit::TestCase
122
122
  page = @agent.get('http://localhost/')
123
123
 
124
124
  node = Struct.new(:href, :inner_text).new('http://localhost/', 'blah')
125
- link = WWW::Mechanize::Page::Link.new(node, nil, nil)
125
+ link = Mechanize::Page::Link.new(node, nil, nil)
126
126
  assert(@agent.visited?(link))
127
127
 
128
128
  node = Struct.new(:href, :inner_text).new('http://localhost', 'blah')
129
- link = WWW::Mechanize::Page::Link.new(node, nil, nil)
129
+ link = Mechanize::Page::Link.new(node, nil, nil)
130
130
  assert(@agent.visited?(link))
131
131
  end
132
132
 
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class HistoryAddedTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_history_added_gets_called
@@ -2,37 +2,37 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestCheckBoxes < Test::Unit::TestCase
4
4
  def test_field
5
- f = WWW::Mechanize::Form::Field.new('a&amp;b', 'a&amp;b')
5
+ f = Mechanize::Form::Field.new('a&amp;b', 'a&amp;b')
6
6
  assert_equal('a&b', f.name)
7
7
  assert_equal('a&b', f.value)
8
8
 
9
- f = WWW::Mechanize::Form::Field.new('a&b', 'a&b')
9
+ f = Mechanize::Form::Field.new('a&b', 'a&b')
10
10
  assert_equal('a&b', f.name)
11
11
  assert_equal('a&b', f.value)
12
12
 
13
- f = WWW::Mechanize::Form::Field.new('a&#38;b', 'a&#38;b')
13
+ f = Mechanize::Form::Field.new('a&#38;b', 'a&#38;b')
14
14
  assert_equal('a&b', f.name)
15
15
  assert_equal('a&b', f.value)
16
16
  end
17
17
 
18
18
  def test_file_upload
19
- f = WWW::Mechanize::Form::FileUpload.new('a&amp;b', 'a&amp;b')
19
+ f = Mechanize::Form::FileUpload.new('a&amp;b', 'a&amp;b')
20
20
  assert_equal('a&b', f.name)
21
21
  assert_equal('a&b', f.file_name)
22
22
 
23
- f = WWW::Mechanize::Form::FileUpload.new('a&b', 'a&b')
23
+ f = Mechanize::Form::FileUpload.new('a&b', 'a&b')
24
24
  assert_equal('a&b', f.name)
25
25
  assert_equal('a&b', f.file_name)
26
26
  end
27
27
 
28
28
  def test_image_button
29
- f = WWW::Mechanize::Form::ImageButton.new('a&amp;b', 'a&amp;b')
29
+ f = Mechanize::Form::ImageButton.new('a&amp;b', 'a&amp;b')
30
30
  assert_equal('a&b', f.name)
31
31
  assert_equal('a&b', f.value)
32
32
  end
33
33
 
34
34
  def test_radio_button
35
- f = WWW::Mechanize::Form::RadioButton.new('a&amp;b', 'a&amp;b', nil, nil)
35
+ f = Mechanize::Form::RadioButton.new('a&amp;b', 'a&amp;b', nil, nil, nil)
36
36
  assert_equal('a&b', f.name)
37
37
  assert_equal('a&b', f.value)
38
38
  end