Sha256: 335c381cf56232e3e5f88c54f14d1093ae6517c53afc9cd6e38f219b5dfe7544

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

# include Test::Unit::Assertions
class IFD_Assertion
  # Assert 2 values
  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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
Ifd_Mobile-1.5.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.7 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.4 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.3 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.2 lib/Ifd_Mobile/methods/IFD_Assertion.rb