0
# A refactoring of TestResponse to allow the same behavior to be applied
0
# to the "real" CgiResponse class in integration tests.
0
module TestResponseBehavior #:nodoc:
0
- #
the response code of the request
0
+ #
The response code of the request
0
headers['Status'][0,3].to_i rescue 0
0
- #
returns a String to ensure compatibility with Net::HTTPResponse
0
+ #
Returns a String to ensure compatibility with Net::HTTPResponse
0
headers['Status'].to_s.split(' ')[0]
0
headers['Status'].to_s.split(' ',2)[1]
0
- #
was the response successful?
0
+ #
Was the response successful?
0
- #
was the URL not found?
0
+ #
Was the URL not found?
0
(300..399).include?(response_code)
0
- #
was there a server-side error?
0
+ #
Was there a server-side error?
0
(500..599).include?(response_code)
0
alias_method :server_error?, :error?
0
- #
returns the redirection location or nil
0
+ #
Returns the redirection location or nil
0
- #
does the redirect location match this regexp pattern?
0
+ #
Does the redirect location match this regexp pattern?
0
def redirect_url_match?( pattern )
0
return false if redirect_url.nil?
0
p = Regexp.new(pattern) if pattern.class == String
0
p.match(redirect_url) != nil
0
- #
returns the template path of the file which was used to
0
+ #
Returns the template path of the file which was used to
0
# render this response (or nil)
0
def rendered_file(with_controller=false)
0
unless template.first_render.nil?
0
- #
was this template rendered by a file?
0
+ #
Was this template rendered by a file?
0
def rendered_with_file?
0
- #
a shortcut to the flash (or an empty hash if no flash.. hey! that rhymes!)0
+ #
A shortcut to the flash. Returns an empyt hash if no session flash exists.0
!session['flash'].empty?
0
- #
do we have a flash that has contents?
0
+ #
Do we have a flash that has contents?
0
def has_flash_with_contents?
0
- #
does the specified flash object exist?
0
+ #
Does the specified flash object exist?
0
def has_flash_object?(name=nil)
0
- #
does the specified object exist in the session?
0
+ #
Does the specified object exist in the session?
0
def has_session_object?(name=nil)
0
- #
a shortcut to the template.assigns
0
+ #
A shortcut to the template.assigns
0
- #
does the specified template object exist?
0
+ #
Does the specified template object exist?
0
def has_template_object?(name=nil)
0
!template_objects[name].nil?
0
# Returns the response cookies, converted to a Hash of (name => CGI::Cookie) pairs
0
- #
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
0
+ #
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
0
headers['cookie'].inject({}) { |hash, cookie| hash[cookie.name] = cookie; hash }
Comments
No one has commented yet.