mechanize 2.0.pre.2 → 2.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 (46) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.rdoc +22 -0
  3. data/Manifest.txt +11 -8
  4. data/Rakefile +2 -2
  5. data/examples/flickr_upload.rb +6 -7
  6. data/examples/mech-dump.rb +0 -2
  7. data/examples/proxy_req.rb +0 -2
  8. data/examples/rubyforge.rb +1 -3
  9. data/examples/spider.rb +2 -3
  10. data/lib/mechanize.rb +228 -680
  11. data/lib/mechanize/form/field.rb +1 -1
  12. data/lib/mechanize/history.rb +23 -5
  13. data/lib/mechanize/http.rb +3 -0
  14. data/lib/mechanize/http/agent.rb +738 -0
  15. data/lib/mechanize/inspect.rb +2 -2
  16. data/lib/mechanize/page.rb +101 -42
  17. data/lib/mechanize/page/frame.rb +24 -17
  18. data/lib/mechanize/page/link.rb +72 -54
  19. data/lib/mechanize/page/meta_refresh.rb +56 -0
  20. data/lib/mechanize/response_read_error.rb +27 -0
  21. data/test/htdocs/frame_referer_test.html +10 -0
  22. data/test/htdocs/tc_referer.html +4 -0
  23. data/test/test_frames.rb +9 -0
  24. data/test/test_history.rb +74 -98
  25. data/test/test_mechanize.rb +334 -812
  26. data/test/test_mechanize_form.rb +32 -3
  27. data/test/{test_textarea.rb → test_mechanize_form_textarea.rb} +1 -1
  28. data/test/test_mechanize_http_agent.rb +697 -0
  29. data/test/test_mechanize_link.rb +83 -0
  30. data/test/test_mechanize_page_encoding.rb +147 -0
  31. data/test/test_mechanize_page_link.rb +379 -0
  32. data/test/test_mechanize_page_meta_refresh.rb +115 -0
  33. data/test/test_pretty_print.rb +1 -1
  34. data/test/test_referer.rb +29 -5
  35. data/test/test_response_code.rb +21 -20
  36. data/test/test_robots.rb +13 -17
  37. data/test/test_scheme.rb +1 -1
  38. metadata +30 -31
  39. metadata.gz.sig +0 -0
  40. data/lib/mechanize/page/meta.rb +0 -48
  41. data/test/test_form_no_inputname.rb +0 -15
  42. data/test/test_links.rb +0 -146
  43. data/test/test_mechanize_page.rb +0 -224
  44. data/test/test_meta.rb +0 -67
  45. data/test/test_upload.rb +0 -109
  46. data/test/test_verbs.rb +0 -25
@@ -1,109 +0,0 @@
1
- require "helper"
2
-
3
- class UploadMechTest < Test::Unit::TestCase
4
- def setup
5
- @agent = Mechanize.new
6
- @page = @agent.get("http://localhost/file_upload.html")
7
- end
8
-
9
- def test_upload_with_post_param
10
- page = @agent.post('http://localhost/file_upload', {
11
- :name => 'Some file',
12
- :userfile1 => File.open(__FILE__)
13
- })
14
- assert_match(
15
- "Content-Disposition: form-data; name=\"userfile1\"; filename=\"#{File.basename(__FILE__)}\"",
16
- page.body
17
- )
18
- assert page.body.length > File.read(__FILE__).length
19
- end
20
-
21
- def test_form_enctype
22
- assert_equal('multipart/form-data', @page.forms[0].enctype)
23
-
24
- form = @page.forms.first
25
- form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
26
- form.file_uploads.first.mime_type = "text/plain"
27
- form.file_uploads.first.file_data = "Hello World\n\n"
28
-
29
- @page = @agent.submit(form)
30
-
31
- assert_match(
32
- "Content-Disposition: form-data; name=\"userfile1\"; filename=\"helper.rb\"",
33
- @page.body
34
- )
35
- assert_match(
36
- "Content-Disposition: form-data; name=\"name\"",
37
- @page.body
38
- )
39
- assert_match('Content-Type: text/plain', @page.body)
40
- assert_match('Hello World', @page.body)
41
- assert_match('foo[aaron]', @page.body)
42
- end
43
-
44
- def test_form_multipart
45
- assert_equal('multipart/form-data', @page.forms[1].enctype)
46
-
47
- form = @page.forms[1]
48
- form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
49
- form.file_uploads.first.mime_type = "text/plain"
50
- form.file_uploads.first.file_data = "Hello World\n\n"
51
-
52
- @page = @agent.submit(form)
53
-
54
- assert_match(
55
- "Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
56
- @page.body
57
- )
58
- end
59
-
60
- def test_form_read_file
61
- assert_equal('multipart/form-data', @page.forms[1].enctype)
62
-
63
- form = @page.forms[1]
64
- form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
65
-
66
- @page = @agent.submit(form)
67
-
68
- contents = File.open("#{BASE_DIR}/helper.rb", 'rb') { |f| f.read }
69
- assert_match(
70
- "Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
71
- @page.body
72
- )
73
- assert_match(contents, @page.body)
74
- end
75
-
76
- def test_form_io_obj
77
- assert_equal('multipart/form-data', @page.forms[1].enctype)
78
-
79
- form = @page.forms[1]
80
- form.file_uploads.first.file_name = "#{BASE_DIR}/helper.rb"
81
- form.file_uploads.first.file_data = File.open("#{BASE_DIR}/helper.rb", 'rb')
82
-
83
- @page = @agent.submit(form)
84
-
85
- contents = File.open("#{BASE_DIR}/helper.rb", 'rb') { |f| f.read }
86
- assert_match(
87
- "Content-Disposition: form-data; name=\"green[eggs]\"; filename=\"helper.rb\"",
88
- @page.body
89
- )
90
- assert_match(contents, @page.body)
91
- end
92
-
93
- def test_submit_no_file
94
- form = @page.forms.first
95
- form.field_with(:name => 'name').value = 'Aaron'
96
- @page = @agent.submit(form)
97
- assert_match('Aaron', @page.body)
98
- assert_match(
99
- "Content-Disposition: form-data; name=\"userfile1\"; filename=\"\"",
100
- @page.body
101
- )
102
- end
103
-
104
- def test_no_value
105
- form = @page.form('value_test')
106
- assert_nil(form.file_uploads.first.value)
107
- assert_nil(form.file_uploads.first.file_name)
108
- end
109
- end
@@ -1,25 +0,0 @@
1
- require "helper"
2
-
3
- class VerbsTest < Test::Unit::TestCase
4
- def setup
5
- @agent = Mechanize.new
6
- end
7
-
8
- def test_put
9
- page = @agent.put('http://localhost/verb', 'foo')
10
- assert_equal 1, @agent.history.length
11
- assert_equal 'PUT', page.header['X-Request-Method']
12
- end
13
-
14
- def test_delete
15
- page = @agent.delete('http://localhost/verb', { 'q' => 'foo' })
16
- assert_equal 1, @agent.history.length
17
- assert_equal 'DELETE', page.header['X-Request-Method']
18
- end
19
-
20
- def test_head
21
- page = @agent.head('http://localhost/verb', { 'q' => 'foo' })
22
- assert_equal 0, @agent.history.length
23
- assert_equal 'HEAD', page.header['X-Request-Method']
24
- end
25
- end