aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/http_mock.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activeresource/lib/active_resource/http_mock.rb')
-rw-r--r--activeresource/lib/active_resource/http_mock.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb
index e085a05f6d..3bfd536b29 100644
--- a/activeresource/lib/active_resource/http_mock.rb
+++ b/activeresource/lib/active_resource/http_mock.rb
@@ -9,8 +9,8 @@ module ActiveResource
# requests.
#
# To test your Active Resource model, you simply call the ActiveResource::HttpMock.respond_to
- # method with an attached block. The block declares a set of URIs with expected input, and the output
- # each request should return. The passed in block has any number of entries in the following generalized
+ # method with an attached block. The block declares a set of URIs with expected input, and the output
+ # each request should return. The passed in block has any number of entries in the following generalized
# format:
#
# mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {})
@@ -29,7 +29,7 @@ module ActiveResource
# <tt>request_headers</tt> listed above.
#
# In order for a mock to deliver its content, the incoming request must match by the <tt>http_method</tt>,
- # +path+ and <tt>request_headers</tt>. If no match is found an InvalidRequestError exception
+ # +path+ and <tt>request_headers</tt>. If no match is found an +InvalidRequestError+ exception
# will be raised showing you what request it could not find a response for and also what requests and response
# pairs have been recorded so you can create a new mock for that request.
#
@@ -80,7 +80,7 @@ module ActiveResource
class << self
- # Returns an array of all request objects that have been sent to the mock. You can use this to check
+ # Returns an array of all request objects that have been sent to the mock. You can use this to check
# if your model actually sent an HTTP request.
#
# ==== Example
@@ -105,7 +105,7 @@ module ActiveResource
end
# Returns the list of requests and their mocked responses. Look up a
- # response for a request using responses.assoc(request).
+ # response for a request using <tt>responses.assoc(request)</tt>.
def responses
@@responses ||= []
end
@@ -299,6 +299,8 @@ module ActiveResource
end
end
+ # Returns true if code is 2xx,
+ # false otherwise.
def success?
code.in?(200..299)
end
@@ -311,6 +313,8 @@ module ActiveResource
headers[key] = value
end
+ # Returns true if the other is a Response with an equal body, equal message
+ # and equal headers. Otherwise it returns false.
def ==(other)
if (other.is_a?(Response))
other.body == body && other.message == message && other.headers == headers