Permalink
Browse files

Test can_retry?

Net::HTTP::Persistent#can_retry? was not tested previously.

Tests were added to support Ruby 2.0's built in reconnect and retry when
a request fails.
  • Loading branch information...
1 parent 7993cc9 commit a84d0262f83972a13700d77a28894e6e68305524 @drbrain committed Feb 9, 2013
Showing with 21 additions and 1 deletion.
  1. +1 −1 lib/net/http/persistent.rb
  2. +20 −0 test/test_net_http_persistent.rb
@@ -682,7 +682,7 @@ def idempotent? req
# Is the request idempotent or is retry_change_requests allowed
def can_retry? req
- retry_change_requests or idempotent?(req)
+ @retry_change_requests or idempotent?(req)
end
if RUBY_VERSION > '1.9' then
@@ -217,6 +217,26 @@ def test_ca_file_equals
assert_equal 1, @http.ssl_generation
end
+ def test_can_retry_eh_idempotent
+ head = Net::HTTP::Head.new '/'
+
+ assert @http.can_retry? head
+
+ post = Net::HTTP::Post.new '/'
+
+ refute @http.can_retry? post
+ end
+
+ def test_can_retry_eh_change_requests
+ post = Net::HTTP::Post.new '/'
+
+ refute @http.can_retry? post
+
+ @http.retry_change_requests = true
+
+ assert @http.can_retry? post
+ end
+
def test_cert_store_equals
@http.cert_store = :cert_store

0 comments on commit a84d026

Please sign in to comment.