Class: IFD_Assertion

Inherits:
Object
  • Object
show all
Defined in:
lib/Ifd_Mobile/methods/IFD_Assertion.rb

Overview

include Test::Unit::Assertions

Class Method Summary collapse

Class Method Details

.assert_string_contain(expected, actual) ⇒ Object



33
34
35
36
37
# File 'lib/Ifd_Mobile/methods/IFD_Assertion.rb', line 33

def self.assert_string_contain(expected, actual)
  unless (actual.to_s).include? (expected.to_s)
    raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
  end
end

.assert_string_equal(expected, actual) ⇒ Object



39
40
41
42
43
# File 'lib/Ifd_Mobile/methods/IFD_Assertion.rb', line 39

def self.assert_string_equal(expected, actual)
  if expected.to_s != actual.to_s
    raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
  end
end

.reg_compare(sActual, regValue, isSpecialChar = false) ⇒ Object

Assert 2 values



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/Ifd_Mobile/methods/IFD_Assertion.rb', line 4

def self.reg_compare sActual, regValue, isSpecialChar=false
  begin
    if !isSpecialChar
      sActual = sActual.strip
      regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
    end
  rescue StandardError => myStandardError
    put_log "\n>>> Error: #{myStandardError}"
  end

  # put_log "\nsActual:#{sActual}, regValue:#{regValue}"
  if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
    return true
  end

  if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
    return false
  end

  if (!sActual.nil? and !sActual.empty?)
    sCookActual = sActual.gsub(/\n|\r/, " ")
    if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
      return true
    end
  end

  return false
end