Module: Outpost::Expectations::ResponseCode

Included in:
Scouts::Http
Defined in:
lib/outpost/expectations/response_code.rb

Overview

Module containing response_code logic. It is the simplest of all, it is a simple direct equality check. Extend your Scout to win instant response_code checking.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Installs the response code expectation



8
9
10
# File 'lib/outpost/expectations/response_code.rb', line 8

def self.extended(base)
  base.expect :response_code, base.method(:evaluate_response_code)
end

Instance Method Details

#evaluate_response_code(scout, response_code) ⇒ Object

Method that will be used as an expectation to evaluate response code



13
14
15
16
17
18
19
# File 'lib/outpost/expectations/response_code.rb', line 13

def evaluate_response_code(scout, response_code)
  if response_code.is_a?(Array) || response_code.is_a?(Range)
    response_code.include?(scout.response_code)
  else
    scout.response_code == response_code.to_i
  end
end