Sha256: 0442c2129bdc6a4c5d6f420d9b2ba3de0b35e2e7fcdbb844d76dec3d9e942cb5

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

class ResponseHeaderChecker < Checker

  # checks given header against the given expepctation and returns a result object
  def check
    result = Result.new(@testcase, @response)
    @testcase.response_expectation['headers'].each_pair do |header_name, header_value|
      if is_regex?(header_value)
        if not (excluded?(header_name) or regex_matches?(header_value, @response.headers[header_name]))
          result.succeeded = false
          result.error_message = " expected header identifier --#{header_name}-- to match regex --#{header_value}--\n got --#{@response.headers[header_name]}--"
        end
      else
        if not (excluded?(header_name) or string_matches?(header_value, @response.headers[header_name]))
          result.succeeded = false
          result.error_message = " expected header identifier --#{header_name}-- to match --#{header_value}--\n got --#{@response.headers[header_name]}--"
        end
      end
    end unless (@testcase.response_expectation['headers'].nil? or @testcase.response_expectation['headers'].empty?)
    result
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
apirunner-0.3.3 lib/plugins/response_header_checker.rb
apirunner-0.3.2 lib/plugins/response_header_checker.rb
apirunner-0.3.1 lib/plugins/response_header_checker.rb
apirunner-0.3.0 lib/plugins/response_header_checker.rb
apirunner-0.2.8 lib/plugins/response_header_checker.rb
apirunner-0.2.7 lib/plugins/response_header_checker.rb
apirunner-0.2.6 lib/plugins/response_header_checker.rb