So I have a class that does this:
def perform
@response = Net::HTTP.new(url.host, url.port).start {|http|
http.request(do_post) }
unless @response.is_a?(Net::HTTPSuccess) ||
@response.is_a?(Net::HTTPRedirection)
@response.error!
end
end
def do_post
Net::HTTP::Post.new(url.request_uri).tap do |req|
req.set_form_data({:foo => “Bar”)
end
end
def url
“http://myurl.com/something”
end
…
My question is-- Is there anything worth testing here? Since this is
involving a 3rd party API, I shouldn’t perform an actual post (for many
reasons)… On the other hand, this is pretty much all Net::HTTP
functionality
so I should be able to rely on it just working as is.
The only thing I can see in this that MIGHT be worth testing is that
@response
raises an error if it’s not a HTTPSuccess or HTTPRedirection, but— is
that
really worth doing?
Thank you in advance for your input.
Patrick J. Collins
http://collinatorstudios.com