FakeWeb

Open source helper for faking web requests
Download

FakeWeb Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Blaine Cook
  • Publisher web site:
  • http://romeda.org/
  • Operating Systems:
  • Mac OS X
  • File Size:
  • 24 KB

FakeWeb Tags


FakeWeb Description

Open source helper for faking web requests FakeWeb is a helper for faking web requests. This makes testing easier, because you can decouple your test environment from live services without modifying code. FakeWeb allows for a range of request behaviour, from simple stubbing of HTTP responses to re-playing complete recorded responses.In addition to the conceptual advantage of having idempotent request behaviour, FakeWeb makes tests run faster than if they were made to remote (or even local) web servers. FakeWeb also makes it possible to run tests without a network connection or in situations where the server is behind a firewall or has host based access controls.FakeWeb is tested with Net::HTTP and OpenURI. FakeWeb should work with any web client library that uses Net::HTTP for its underlying requests (e.g., Ruby/Amazon, soap4r, Flickr.rb, etc.) What's New in This Release: · add lib/fakeweb.rb so you can require "fakeweb" as well · fix compatibility with Ruby 1.9.1 · fix that newlines in file-based responses could be doubled in the response object's body · fix unnecessary munging of the transfer-encoding header, which improves compatibility with mechanize · fix a test and the RCov dependency to be compatible with JRuby · remove an unnecessary redefinition of OpenURI::HTTPError · rearrange implementation code into separate files, one per class · fix a bug where FakeWeb.response_for would raise if the request wasn't registered · add HTTP method support, so FakeWeb takes both the URI and method into account for registration, requests, and responses. Backwards-compatible with the old method signatures, which didn't have a method param. · start work on Ruby 1.9 compatibility · add FakeWeb.allow_net_connect= to enable/disable the pass-through to Net::HTTP for unregistered URIs · remove setup.rb, since most people use RubyGems · fix that 'http://example.com/?' (empty query) matches a registered 'http://example.com/', and vice-versa · improve the test suite to not rely on an internet connection · use `rake test` instead of `rake tests` · fix an incompatibility with Ruby 1.8.6 p36 where you'd get "Errno::EINTR: Interrupted system call" exceptions in Socket#sysread for any non-faked request · response rotation: you can now optionally call FakeWeb.register_uri with an array of options hashes; these are used, in order, to respond to repeated requests (to repeat a response more than once before rotating, use the :times option). Once you run out of responses, further requests always receive the last response. · add support for Net::HTTP's undocumented full-URI request style (fixes URI::InvalidURIErrors that you might see in older libraries) · sort query params before storing internally, so that http://example.com/?a=1&b=2 and http://example.com/?b=2&a=1 are considered the same URL (although this is technically incorrect, it's much more convenient--most web apps work that way, and Net::HTTP's use of a hash to pass query params means that the order in which FakeWeb stores them can be unpredictable) · add support for ports in URLs, so that http://example.com/ and http://example.com:3000/ are not the same · fix for non-faked SSL requests failing with "Unable to create local socket" · update Rakefile to fix warning about deprecated code


FakeWeb Related Software