0
module Merb::Test::Rspec::ControllerMatchers
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ # Boolean:: True if the status code is in the range 300..305 or 307.
0
[307, *(300..305)].include?(target.respond_to?(:status) ? target.status : target)
0
+ # String:: The failure message.
0
"expected#{inspect_target} to redirect"
0
+ # String:: The failure message to be displayed in negative matches.
0
def negative_failure_message
0
"expected#{inspect_target} not to redirect"
0
+ # String:: The controller and action name.
0
" #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
+ # String:: The expected location
0
def initialize(expected)
0
+ # target<Merb::Controller>:: The controller to match
0
+ # True if the controller status is redirect and the locations match.
0
@target, @location = target, target.headers['Location']
0
@redirected = BeRedirect.new.matches?(target.status)
0
@location == @expected && @redirected
0
+ # String:: The failure message.
0
msg = "expected #{inspect_target} to redirect to <#{@expected}>, but "
0
msg << "there was no redirection"
0
+ # String:: The failure message to be displayed in negative matches.
0
def negative_failure_message
0
"expected #{inspect_target} not to redirect to <#{@expected}>, but did anyway"
0
+ # String:: The controller and action name.
0
"#{@target.controller_name}##{@target.action_name}"
0
+ # String:: Either the target's location header or the target itself.
0
@target.respond_to?(:headers) ? @target.headers['Location'] : @target
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ # Boolean:: True if the status code is in the range 200..207.
0
(200..207).include?(status_code)
0
+ # String:: The failure message.
0
"expected#{inspect_target} to be successful but was #{status_code}"
0
+ # String:: The failure message to be displayed in negative matches.
0
def negative_failure_message
0
"expected#{inspect_target} not to be successful but it was #{status_code}"
0
+ # String:: The controller and action name.
0
" #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
+ # Fixnum:: Either the target's status or the target itself.
0
@target.respond_to?(:status) ? @target.status : @target
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ # Boolean:: True if the status code is in the range 400..417.
0
(400..417).include?(status_code)
0
+ # String:: The failure message.
0
"expected#{inspect_target} to be missing but was #{status_code}"
0
+ # String:: The failure message to be displayed in negative matches.
0
def negative_failure_message
0
"expected#{inspect_target} not to be missing but it was #{status_code}"
0
+ # String:: The controller and action name.
0
" #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
+ # Fixnum:: Either the target's status or the target itself.
0
@target.respond_to?(:status) ? @target.status : @target
0
- # Passes if the target was redirected, or the target is a redirection (300 level) response code.
0
+ # Passes if the target was redirected, or the target is a redirection (300
0
+ # level) response code.
0
# # Passes if the controller was redirected
0
# controller.should redirect
0
# # Also works if the target is the response code
0
# controller.status.should redirect
0
# valid HTTP Redirection codes:
0
# * 300: Multiple Choices
0
# * 301: Moved Permanently
0
alias_method :be_redirection, :redirect
0
# Passes if the target was redirected to the expected location.
0
- # A relative or absolute url.
0
+ # expected<String>:: A relative or absolute url.
0
# # Passes if the controller was redirected to http://example.com/
0
# controller.should redirect_to('http://example.com/')
0
def redirect_to(expected)
0
RedirectTo.new(expected)
0
alias_method :be_redirection_to, :redirect_to
0
- # Passes if the request that generated the target was successful,
0
- # or the target is a success (200 level) response code.
0
+ # Passes if the request that generated the target was successful, or the
0
+ # target is a success (200 level) response code.
0
# # Passes if the controller call was successful
0
# controller.should respond_successfully
0
# # Also works if the target is the response code
0
# controller.status.should respond_successfully
0
# valid HTTP Success codes:
0
def respond_successfully
0
alias_method :be_successful, :respond_successfully
0
- # Passes if the request that generated the target was missing,
0
- # or the target is a client-side error (400 level) response code.
0
+ # Passes if the request that generated the target was missing, or the target
0
+ # is a client-side error (400 level) response code.
0
# # Passes if the controller call was unknown or not understood
0
# controller.should be_missing
0
# # Also passes if the target is a response code
0
# controller.status.should be_missing
0
# valid HTTP Client Error codes:
0
alias_method :be_client_error, :be_missing