README.rdoc in fakeweb-1.2.0 vs README.rdoc in fakeweb-1.2.1

- old
+ new

@@ -9,18 +9,23 @@ The latest release of FakeWeb is once again available from your friendly RubyForge mirror. Just install the gem: sudo gem install fakeweb +Note: the gem was previously available as +FakeWeb+ (capital letters), but now +all versions are simply registered as +fakeweb+. If you have any old +FakeWeb+ +gems lying around, remove them: <tt>sudo gem uninstall FakeWeb</tt> + == Help and discussion RDocs for the current release are available at http://fakeweb.rubyforge.org. There's a mailing list for questions and discussion at http://groups.google.com/group/fakeweb-users. +The main source repository is http://github.com/chrisk/fakeweb. == Examples Start by requiring FakeWeb: @@ -84,10 +89,25 @@ req.delete("/posts/1").body # => "Post 1 deleted" req.delete("/posts/1").body # => "Post not found" req.delete("/posts/1").body # => "Post not found" end +=== Using HTTP basic authentication + +You can stub requests that use basic authentication with +userinfo+ strings in +the URIs: + + FakeWeb.register_uri("http://example.com/secret", :string => "Unauthorized", :status => ["401", "Unauthorized"]) + FakeWeb.register_uri("http://user:pass@example.com/secret", :string => "Authorized") + + Net::HTTP.start("example.com") do |http| + req = Net::HTTP::Get.new("/secret") + http.request(req) # => "Unauthorized" + req.basic_auth("user", "pass") + http.request(req) # => "Authorized" + end + === Clearing registered URIs The FakeWeb registry is a singleton that lasts for the duration of your program, maintaining every fake response you register. If needed, you can clean out the registry and remove all registered URIs: @@ -157,6 +177,6 @@ You should have received a copy of the GNU General Public License along with FakeWeb; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -See <tt>LICENSE.txt</tt> for the full terms. \ No newline at end of file +See <tt>LICENSE.txt</tt> for the full terms.