Module: AppTester::Checker Abstract

Extended by:
Checker
Included in:
Checker
Defined in:
lib/app-tester/checker.rb

Overview

This module is abstract.

Check module to be used within a test snippet. This can be extended to have more checks

Instance Method Summary collapse

Instance Method Details

#status(response, overwrite_output = nil, fail = false) ⇒ NilClass

Check the status of a response and output to cmd

Parameters:

  • response (Faraday::Response)

    the response object from Faraday

  • overwrite_output (NilClass, TrueClass) (defaults to: nil)

    if we should overwrite default output. Useful for setting custom messages

  • fail (TrueClass, FalseClass) (defaults to: false)

    if we should force the script to halt execution

Returns:

  • (NilClass)

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/app-tester/checker.rb', line 13

def status(response, overwrite_output=nil, fail=false)
  if response.status == 200
    if overwrite_output.nil?
      puts "#{AppTester::Utils::Strings::SUCCESS} got status #{response.status}"
    else
      puts "#{AppTester::Utils::Strings::SUCCESS} #{overwrite_output}"
    end
  else
    if overwrite_output.nil?
      puts "#{AppTester::Utils::Strings::WARNING} got status #{response.status}"
    else
      puts "#{AppTester::Utils::Strings::WARNING} #{overwrite_output}"
    end
    exit(1) if fail
  end
end