Skip to content
Browse files

Enable request pass-through by default, add docs for allow_net_connect

  • Loading branch information...
1 parent 494dc5c commit 071b998fc83bf85132ec0c54e03708f954339eef @chrisk chrisk committed Dec 22, 2008
Showing with 21 additions and 8 deletions.
  1. +21 −8 lib/fake_web.rb
View
29 lib/fake_web.rb
@@ -29,15 +29,28 @@ module FakeWeb
def self.clean_registry
Registry.instance.clean_registry
end
-
- def self.allow_net_connect=(value)
- @allow_net_connect = value
+
+ # Enables or disables real HTTP connections for requests that don't match
+ # registered URIs.
+ #
+ # If you set <tt>FakeWeb.allow_net_connect = false</tt> and subsequently try
+ # to make a request to a URI you haven't registered with #register_uri, an
+ # exception will be raised. This is handy when you want to make sure your
+ # tests are self-contained, or want to catch the scenario when a URI is
+ # changed in implementation code without a corresponding test change.
+ #
+ # When <tt>FakeWeb.allow_net_connect = true</tt> (the default), requests to
+ # URIs not registered with FakeWeb are passed through to Net::HTTP.
+ def self.allow_net_connect=(allowed)
+ @allow_net_connect = allowed
end
-
- # when a request is made to an URI that isn't registered,
- # raise an error rather than making a real HTTP connection
- self.allow_net_connect = false
-
+
+ # Enable pass-through to Net::HTTP by default.
+ self.allow_net_connect = true
+
+ # Returns +true+ if requests to URIs not registered with FakeWeb are passed
+ # through to Net::HTTP for normal processing (the default). Returns +false+
+ # if an exception is raised for these requests.
def self.allow_net_connect?
@allow_net_connect
end

0 comments on commit 071b998

Please sign in to comment.
Something went wrong with that request. Please try again.