Permalink
Browse files

Fix a bug where FakeWeb.response_for would raise if the request wasn'…

…t registered
  • Loading branch information...
1 parent 26b7c6c commit 28728a75bcf77b15cd2009fdfa34a226645e41d4 @chrisk chrisk committed Jan 5, 2009
Showing with 5 additions and 0 deletions.
  1. +1 −0 lib/fake_web.rb
  2. +4 −0 test/test_fake_web.rb
View
1 lib/fake_web.rb
@@ -184,6 +184,7 @@ def registered_uri(method, uri)
def response_for(method, uri, &block)
responses = registered_uri(method, uri)
+ return nil if responses.nil?
next_response = responses.last
responses.each { |response|
View
4 test/test_fake_web.rb
@@ -100,6 +100,10 @@ def test_response_for_with_registered_uri
assert_equal 'test example content', FakeWeb.response_for('http://mock/test_example.txt').body
end
+ def test_response_for_with_unknown_uri
+ assert_equal nil, FakeWeb.response_for(:get, 'http://example.com/')
+ end
+
def test_response_for_with_put_method
FakeWeb.register_uri(:put, "http://example.com", :string => "response")
assert_equal 'response', FakeWeb.response_for(:put, "http://example.com").body

0 comments on commit 28728a7

Please sign in to comment.