Class: ResponseCodeChecker

Inherits:
Checker
  • Object
show all
Defined in:
lib/plugins/plug02_response_code_checker.rb

Instance Method Summary collapse

Methods inherited from Checker

available_plugins, #initialize

Constructor Details

This class inherits a constructor from Checker

Instance Method Details

#checkObject

checks the given responses status code against the one in the expectation and returns result object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/plugins/plug02_response_code_checker.rb', line 4

def check
  result = Result.new(@testcase, @response)
  begin
    if not @testcase.response_expectation['status_code'].to_s == @response.code.to_s
      result.succeeded = false
      result.error_message = " expected response code --#{@testcase.response_expectation['status_code']}--\n got response code --#{@response.code}--"
    end
   rescue Exception => e
     result.succeeded = false
     result.error_message = " unexpected error while parsing testcase/response. Check your testcase format!"
     result.error_message = "\n\n Exception occured: #{e}"
   end
  result
end