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.

Files changed (48) hide show
  1. data/CHANGELOG +17 -0
  2. data/EXAMPLES +23 -44
  3. data/NOTES +49 -0
  4. data/lib/mechanize.rb +95 -80
  5. data/lib/mechanize/cookie.rb +147 -148
  6. data/lib/mechanize/cookie.rb.rej +16 -0
  7. data/lib/mechanize/errors.rb +29 -0
  8. data/lib/mechanize/form.rb +211 -186
  9. data/lib/mechanize/form_elements.rb +31 -71
  10. data/lib/mechanize/list.rb +34 -0
  11. data/lib/mechanize/mech_version.rb +3 -1
  12. data/lib/mechanize/module.rb +1 -1
  13. data/lib/mechanize/page.rb +162 -180
  14. data/lib/mechanize/page_elements.rb +53 -40
  15. data/lib/mechanize/parsing.rb +11 -3
  16. data/lib/mechanize/pluggable_parsers.rb +147 -0
  17. data/test/data/server.crt +14 -0
  18. data/test/data/server.csr +11 -0
  19. data/test/data/server.key +18 -0
  20. data/test/data/server.pem +15 -0
  21. data/test/htdocs/no_title_test.html +6 -0
  22. data/test/parse.rb +39 -0
  23. data/test/proxy.rb +30 -0
  24. data/test/server.rb +2 -0
  25. data/test/servlets.rb +8 -0
  26. data/test/ssl_server.rb +49 -0
  27. data/test/tc_authenticate.rb +8 -6
  28. data/test/tc_cookie_class.rb +28 -18
  29. data/test/tc_cookie_jar.rb +88 -27
  30. data/test/tc_cookies.rb +41 -44
  31. data/test/tc_errors.rb +9 -23
  32. data/test/tc_forms.rb +36 -32
  33. data/test/tc_frames.rb +6 -4
  34. data/test/tc_links.rb +7 -6
  35. data/test/tc_mech.rb +43 -46
  36. data/test/tc_page.rb +24 -0
  37. data/test/tc_pluggable_parser.rb +103 -0
  38. data/test/tc_post_form.rb +41 -0
  39. data/test/tc_proxy.rb +25 -0
  40. data/test/tc_response_code.rb +13 -10
  41. data/test/tc_save_file.rb +25 -0
  42. data/test/tc_ssl_server.rb +27 -0
  43. data/test/tc_upload.rb +8 -6
  44. data/test/tc_watches.rb +5 -2
  45. data/test/test_includes.rb +3 -3
  46. data/test/ts_mech.rb +11 -2
  47. metadata +100 -86
  48. 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
- agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
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
- agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
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
- agent = WWW::Mechanize.new
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)
@@ -1,5 +1,5 @@
1
1
  module TestMethods
2
- def setup
3
- @port = 2000
4
- end
2
+ PORT = 2000
3
+ PROXYPORT = 2001
4
+ SSLPORT = 2002
5
5
  end
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.8.11.13
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.4.7
7
- date: 2006-06-19 00:00:00 -07:00
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
- - !ruby/object:Gem::Version
23
- version: 0.0.0
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/tc_errors.rb
33
- - test/server.rb
34
- - test/tc_response_code.rb
35
- - test/servlets.rb
36
- - test/tc_cookies.rb
37
- - test/htdocs
38
- - test/tc_forms.rb
39
- - test/tc_upload.rb
40
- - test/tc_links.rb
41
- - test/data
42
- - test/tc_filter.rb
43
- - test/tc_cookie_class.rb
44
- - test/tc_watches.rb
45
- - test/tc_parsing.rb
46
- - test/test_includes.rb
47
- - test/tc_frames.rb
48
- - test/tc_mech.rb
49
- - test/test_mech.rb
50
- - test/ts_mech.rb
51
- - test/tc_cookie_jar.rb
52
- - test/README
53
- - test/tc_authenticate.rb
54
- - test/htdocs/frame_test.html
55
- - test/htdocs/button.jpg
56
- - test/htdocs/form_test.html
57
- - test/htdocs/form_multival.html
58
- - test/htdocs/alt_text.html
59
- - test/htdocs/bad_form_test.html
60
- - test/htdocs/find_link.html
61
- - test/htdocs/index.html
62
- - test/htdocs/google.html
63
- - test/htdocs/form_no_action.html
64
- - test/htdocs/file_upload.html
65
- - test/htdocs/iframe_test.html
66
- - test/data/htpasswd
67
- - lib/mechanize
68
- - lib/mechanize.rb
69
- - lib/mechanize/net-overrides
70
- - lib/mechanize/mech_version.rb
71
- - lib/mechanize/parsing.rb
72
- - lib/mechanize/module.rb
73
- - lib/mechanize/page.rb
74
- - lib/mechanize/cookie.rb
75
- - lib/mechanize/form_elements.rb
76
- - lib/mechanize/list.rb
77
- - lib/mechanize/form.rb
78
- - lib/mechanize/page_elements.rb
79
- - lib/mechanize/net-overrides/net
80
- - lib/mechanize/net-overrides/net/http.rb
81
- - lib/mechanize/net-overrides/net/protocol.rb
82
- - lib/mechanize/net-overrides/net/https.rb
83
- - README
84
- - EXAMPLES
85
- - CHANGELOG
86
- - LICENSE
87
- - NOTES
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
- name: ruby-web
110
- version_requirement:
111
- version_requirements: !ruby/object:Gem::Version::Requirement
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 1.1.0
116
- version:
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