Wednesday, April 18, 2012

ruby Fakeweb error if a Mechanize agent's read_timeout= is called

I'm using Mechanize to spider some websites. While spidering I save pages to files that I use later with Fakeweb to do tests.



My Mechanize agent is created this way:



Mechanize.new do |a| 
a.read_timeout = 20 # doesn't work with Fakeweb?
a.max_history = 1
end


When I run my app enabling Fakeweb to fetch files instead of actual Internet access, my log throws these messages for every uri I try



W, [2011-08-20T18:49:45.764749 #14526]  WARN -- : undefined method `read_timeout=' for #<FakeWeb::StubSocket:0xb72c150c>


If I comment the second line in the above code (# a.read_timeout = 20 ...), it works perfectly. No problem at all. Any idea on how to enable read_timout and make Fakeweb work?



TIA





No comments:

Post a Comment