[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] FakeWeb test helper for Net::HTTP / open-uri web requests

romeda@gmail.com

5/23/2006 11:54:00 PM

Hey All,

I've posted the first release of FakeWeb, a little library to help
with all your http client testing needs. This helper makes it trivial
to setup an idempodent environment for you to test any web service
requests in your applications.

Available on RubyForge, http://rubyforge.org/project...

== Overview
* Force Net::HTTP (and any dependent libraries, e.g. open-uri) to
return arbitrary responses or exceptions for a given set of request
URLs.
* Speed up tests that involve remote HTTP round trips.
* 100% C0 test coverage as reported by rcov
* Works for all regular HTTP requests, as well as Proxied and HTTPS
requests.

== Two-line Example
FakeWeb.register_uri("http://example...., :string => "Hello World")
open("http://example....).string # => "Hello World"

== Another Example
FakeWeb.register_uri("http://example....,
:response => `curl -i
http://www.g...`)
Net::HTTP.get_response("example.com", "/")
# => Net::HTTPResponse equivalent to fetching http://www.g...

Versions 1.0.0 and 1.1.0 are available, the former works with Ruby
1.8.2, and the latter (and all subsequent releases) works with Ruby
1.8.4.

See http://fakeweb.ruby... for more information and
documentation.