def matches?(code)
      path = 'http://test.host/redirect'

      unless @scope.respond_to?(:request) && @scope.respond_to?(:response)
        fail_spec_type and return false
      end
      unless ALLOWED_REQUEST_TYPES.include? @scope.request.class
        fail_request_type and return false
      end
      unless ALLOWED_RESPONSE_TYPES.include? @scope.response.class
        fail_response_type and return false
      end
      @scope.request.env['HTTP_REFERER'] ||= path
      unless code.is_a? Proc
        fail_input_type code and return false
      end
      code.call
      @response = @scope.response
      status_matcher = STATUS_CODE_MATCHER.new :redirect
      unless status_matcher.matches? @response
        fail_status_code status_matcher and return false
      end
      path_matcher = REDIRECT_PATH_MATCHER.new @scope, path
      unless path_matcher.matches? @response
        fail_redirect_path path_matcher and return false
      end
      true
    end
def matches?(code)
      path = 'http://test.host/redirect'

      unless @scope.respond_to?(:request) && @scope.respond_to?(:response)
        fail_spec_type and return false
      end
      unless ALLOWED_REQUEST_TYPES.include? @scope.request.class
        fail_request_type and return false
      end
      unless ALLOWED_RESPONSE_TYPES.include? @scope.response.class
        fail_response_type and return false
      end
      @scope.request.env['HTTP_REFERER'] ||= path
      unless code.is_a? Proc
        fail_input_type code and return false
      end
      code.call
      @response = @scope.response
      status_matcher = STATUS_CODE_MATCHER.new :redirect
      unless status_matcher.matches? @response
        fail_status_code status_matcher and return false
      end
      path_matcher = REDIRECT_PATH_MATCHER.new @scope, path
      unless path_matcher.matches? @response
        fail_redirect_path path_matcher and return false
      end
      true
    end
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
 rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity