mechanize 2.6.0 → 2.7.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.

@@ -39,7 +39,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
39
39
  input_io.write '12345'
40
40
  input_io.rewind
41
41
 
42
- out_io = @agent.auto_io __name__, 1024, input_io
42
+ out_io = @agent.auto_io @NAME, 1024, input_io
43
43
 
44
44
  assert_equal '12345', out_io.string
45
45
 
@@ -56,7 +56,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
56
56
  input_io.write '12345'
57
57
  input_io.rewind
58
58
 
59
- @agent.auto_io __name__, 1, input_io do |chunk|
59
+ @agent.auto_io @NAME, 1, input_io do |chunk|
60
60
  chunks << chunk
61
61
  end
62
62
 
@@ -72,7 +72,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
72
72
  input_io.write '12345'
73
73
  input_io.rewind
74
74
 
75
- out_io = @agent.auto_io __name__, 1, input_io
75
+ out_io = @agent.auto_io @NAME, 1, input_io
76
76
 
77
77
  result = out_io.read
78
78
  assert_equal '12345', result
@@ -88,7 +88,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
88
88
  input_io.write '12345'
89
89
  input_io.rewind
90
90
 
91
- out_io = @agent.auto_io __name__, 1024, input_io do |chunk|
91
+ out_io = @agent.auto_io @NAME, 1024, input_io do |chunk|
92
92
  "x#{chunk}"
93
93
  end
94
94
 
@@ -511,26 +511,22 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
511
511
 
512
512
  def test_request_cookies
513
513
  uri = URI.parse 'http://host.example.com'
514
- Mechanize::Cookie.parse uri, 'hello=world domain=.example.com' do |cookie|
515
- @agent.cookie_jar.add uri, cookie
516
- end
514
+ @agent.cookie_jar.parse 'hello=world domain=.example.com', uri
517
515
 
518
516
  @agent.request_cookies @req, uri
519
517
 
520
- assert_equal 'hello=world domain=.example.com', @req['Cookie']
518
+ assert_equal 'hello="world domain=.example.com"', @req['Cookie']
521
519
  end
522
520
 
523
521
  def test_request_cookies_many
524
522
  uri = URI.parse 'http://host.example.com'
525
523
  cookie_str = 'a=b domain=.example.com, c=d domain=.example.com'
526
- Mechanize::Cookie.parse uri, cookie_str do |cookie|
527
- @agent.cookie_jar.add uri, cookie
528
- end
524
+ @agent.cookie_jar.parse cookie_str, uri
529
525
 
530
526
  @agent.request_cookies @req, uri
531
527
 
532
- expected_variant1 = 'a=b domain=\.example\.com; c=d domain=\.example\.com'
533
- expected_variant2 = 'c=d domain=\.example\.com; a=b domain=\.example\.com'
528
+ expected_variant1 = /a="b domain=\.example\.com"; c="d domain=\.example\.com"/
529
+ expected_variant2 = /c="d domain=\.example\.com"; a="b domain=\.example\.com"/
534
530
 
535
531
  assert_match(/^(#{expected_variant1}|#{expected_variant2})$/, @req['Cookie'])
536
532
  end
@@ -543,9 +539,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
543
539
 
544
540
  def test_request_cookies_wrong_domain
545
541
  uri = URI.parse 'http://host.example.com'
546
- Mechanize::Cookie.parse uri, 'hello=world domain=.example.com' do |cookie|
547
- @agent.cookie_jar.add uri, cookie
548
- end
542
+ @agent.cookie_jar.parse 'hello=world domain=.example.com', uri
549
543
 
550
544
  @agent.request_cookies @req, @uri
551
545
 
@@ -703,6 +697,15 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
703
697
  assert_nil params
704
698
  end
705
699
 
700
+ def test_resolve_slashes
701
+ page = Mechanize::Page.new URI('http://example/foo/'), nil, '', 200, @mech
702
+ uri = '/bar/http://example/test/'
703
+
704
+ resolved = @agent.resolve uri, page
705
+
706
+ assert_equal 'http://example/bar/http://example/test/', resolved.to_s
707
+ end
708
+
706
709
  def test_response_authenticate
707
710
  @agent.add_auth @uri, 'user', 'password'
708
711
 
@@ -1017,6 +1020,14 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1017
1020
  assert_equal 'part', body.read
1018
1021
  end
1019
1022
 
1023
+ def test_response_content_encoding_empty_string
1024
+ @res.instance_variable_set :@header, 'content-encoding' => %w[]
1025
+
1026
+ body = @agent.response_content_encoding @res, StringIO.new('part')
1027
+
1028
+ assert_equal 'part', body.read
1029
+ end
1030
+
1020
1031
  def test_response_content_encoding_tempfile_7_bit
1021
1032
  body_io = tempfile 'part'
1022
1033
 
@@ -1028,7 +1039,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1028
1039
  refute body_io.closed?
1029
1040
  ensure
1030
1041
  begin
1031
- body_io.close! unless body_io.closed?
1042
+ body_io.close! if body_io and not body_io.closed?
1032
1043
  rescue IOError
1033
1044
  # HACK for ruby 1.8
1034
1045
  end
@@ -1043,7 +1054,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1043
1054
  assert_equal 'part', body.read
1044
1055
  assert body_io.closed?
1045
1056
  ensure
1046
- body_io.close! unless body_io.closed?
1057
+ body_io.close! if body_io and not body_io.closed?
1047
1058
  end
1048
1059
 
1049
1060
  def test_response_content_encoding_unknown
@@ -1077,7 +1088,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1077
1088
 
1078
1089
  @agent.response_cookies @res, uri, page
1079
1090
 
1080
- assert_equal ['a=b domain=.example.com'],
1091
+ assert_equal ['a="b domain=.example.com"'],
1081
1092
  @agent.cookie_jar.cookies(uri).map { |c| c.to_s }
1082
1093
  end
1083
1094
 
@@ -1096,7 +1107,10 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1096
1107
  cookies_from_jar = @agent.cookie_jar.cookies(uri)
1097
1108
 
1098
1109
  assert_equal 2, cookies_from_jar.length
1099
- cookies_from_jar.each { |cookie| assert cookies.include? cookie.to_s }
1110
+ assert_equal [
1111
+ 'a="b domain=.example.com"',
1112
+ 'c="d domain=.example.com"',
1113
+ ], cookies_from_jar.sort_by { |c| c.name }.map(&:to_s)
1100
1114
  end
1101
1115
 
1102
1116
  def test_response_cookies_meta
@@ -1115,7 +1129,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1115
1129
 
1116
1130
  @agent.response_cookies @res, uri, page
1117
1131
 
1118
- assert_equal ['a=b domain=.example.com'],
1132
+ assert_equal ['a="b domain=.example.com"'],
1119
1133
  @agent.cookie_jar.cookies(uri).map { |c| c.to_s }
1120
1134
  end
1121
1135
 
@@ -1302,12 +1316,12 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1302
1316
  def @res.content_length() 5 end
1303
1317
  def @res.read_body() yield 'part' end
1304
1318
 
1305
- e = assert_raises EOFError do
1319
+ e = assert_raises Mechanize::ResponseReadError do
1306
1320
  @agent.response_read @res, @req, @uri
1307
1321
  end
1308
1322
 
1309
- assert_equal 'Content-Length (5) does not match response body length (4)',
1310
- e.message
1323
+ assert_equal 'Content-Length (5) does not match response body length (4)' \
1324
+ ' (Mechanize::ResponseReadError)', e.message
1311
1325
  end
1312
1326
 
1313
1327
  def test_response_read_content_length_redirect
@@ -54,6 +54,7 @@ class TestMechanizePageImage < Mechanize::TestCase
54
54
  def test_url
55
55
  assert_equal ".jpg", img('src' => @src).extname
56
56
  assert_equal "http://example/a.jpg", img('src' => @src).url.to_s
57
+ assert_equal "http://example/a%20.jpg", img('src' => 'http://example/a .jpg' ).url.to_s
57
58
  end
58
59
 
59
60
  def test_url_base
@@ -23,7 +23,7 @@ class TestMechanizeXmlFile < Mechanize::TestCase
23
23
  end
24
24
 
25
25
  def test_at
26
- assert_equal 'Perl', @xml.at('language[2]').text
26
+ assert_equal 'Perl', @xml.at('//language[2]').text
27
27
  end
28
28
 
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-03-20 00:00:00.000000000 Z
15
+ date: 2013-05-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: net-http-digest_auth
@@ -74,6 +74,20 @@ dependencies:
74
74
  - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: 1.17.2
77
+ - !ruby/object:Gem::Dependency
78
+ name: http-cookie
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 1.0.0
84
+ type: :runtime
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.0
77
91
  - !ruby/object:Gem::Dependency
78
92
  name: nokogiri
79
93
  requirement: !ruby/object:Gem::Requirement
@@ -154,42 +168,42 @@ dependencies:
154
168
  requirements:
155
169
  - - ~>
156
170
  - !ruby/object:Gem::Version
157
- version: '4.6'
171
+ version: '5.0'
158
172
  type: :development
159
173
  prerelease: false
160
174
  version_requirements: !ruby/object:Gem::Requirement
161
175
  requirements:
162
176
  - - ~>
163
177
  - !ruby/object:Gem::Version
164
- version: '4.6'
178
+ version: '5.0'
165
179
  - !ruby/object:Gem::Dependency
166
180
  name: rdoc
167
181
  requirement: !ruby/object:Gem::Requirement
168
182
  requirements:
169
183
  - - ~>
170
184
  - !ruby/object:Gem::Version
171
- version: '3.10'
185
+ version: '4.0'
172
186
  type: :development
173
187
  prerelease: false
174
188
  version_requirements: !ruby/object:Gem::Requirement
175
189
  requirements:
176
190
  - - ~>
177
191
  - !ruby/object:Gem::Version
178
- version: '3.10'
192
+ version: '4.0'
179
193
  - !ruby/object:Gem::Dependency
180
194
  name: hoe
181
195
  requirement: !ruby/object:Gem::Requirement
182
196
  requirements:
183
197
  - - ~>
184
198
  - !ruby/object:Gem::Version
185
- version: '3.5'
199
+ version: '3.6'
186
200
  type: :development
187
201
  prerelease: false
188
202
  version_requirements: !ruby/object:Gem::Requirement
189
203
  requirements:
190
204
  - - ~>
191
205
  - !ruby/object:Gem::Version
192
- version: '3.5'
206
+ version: '3.6'
193
207
  description: |-
194
208
  The Mechanize library is used for automating interaction with websites.
195
209
  Mechanize automatically stores and sends cookies, follows redirects,
@@ -276,6 +290,7 @@ files:
276
290
  - lib/mechanize/page/meta_refresh.rb
277
291
  - lib/mechanize/parser.rb
278
292
  - lib/mechanize/pluggable_parsers.rb
293
+ - lib/mechanize/prependable.rb
279
294
  - lib/mechanize/redirect_limit_reached_error.rb
280
295
  - lib/mechanize/redirect_not_get_or_head_error.rb
281
296
  - lib/mechanize/response_code_error.rb