fakeweb
fakeweb copied to clipboard
FakeWeb doesn't mimic Net::HTTP's check "#read_body called twice (IOError)"
This should raise Net::HTTPOK#read_body called twice (IOError) (or whatever the appropriate Net::HTTPResponse class is, there) whether or not the request hits FakeWeb:
%w(net/http rubygems fakeweb).each { |it| require it }
FakeWeb.register_uri(:get, "http://example.com", body: "example")
Net::HTTP.new("example.com").request_get("/") do |response|
2.times { response.read_body { |part| p part } }
end
I found this with 1.9.3 p392; need to check the behavior of all the other implementations. I also see some other things in there we're probably not handling correctly, like #read_body's deprecated-but-still-working dest parameter—need to file issues for those.