tests: fix Net::HTTP::Persistent::Error: too many connection resets.

Works around connection reset errors in the test suite by disabling
persistent connections.

  20) Error:
Sources::PixivTest#test_: in all cases fetching source data for a new manga image should get the tags. :
Net::HTTP::Persistent::Error: too many connection resets (due to closed stream - IOError) after 0 requests on 47071328584700, last used 1.842702476 seconds ago
  app/logical/pixiv_web_agent.rb:46:in `build'
  app/logical/sources/strategies/pixiv.rb:104:in `agent'
  app/logical/sources/strategies/pixiv.rb:72:in `get'
  app/logical/sources/site.rb:6:in `get'
  test/unit/sources/pixiv_test.rb:7:in `get_source'
  test/unit/sources/pixiv_test.rb:64:in `block (3 levels) in <class:PixivTest>'

ref: github.com/sparklemotion/mechanize/issues/123
ref: http://www.rubydoc.info/gems/mechanize/Mechanize#retry_change_requests%3D-instance_method
This commit is contained in:
evazion
2017-02-04 00:32:55 -06:00
parent cd3b09b10a
commit 98b0b2c5d8
2 changed files with 3 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ class PixivWebAgent
def self.build
mech = Mechanize.new
mech.keep_alive = false
phpsessid = Cache.get(SESSION_CACHE_KEY)
comicsessid = Cache.get(COMIC_SESSION_CACHE_KEY)

View File

@@ -131,6 +131,7 @@ module Sources
def agent
@agent ||= begin
mech = Mechanize.new
mech.keep_alive = false
session = Cache.get("nico-seiga-session")
if session