module DhEasy::Test

Constants

VERSION

Gem version

Public Class Methods

disable_test_mode() click to toggle source

Disable test mode inside executors.

# File lib/dh_easy/test.rb, line 16
def self.disable_test_mode
  @@test_mode = false
end
enable_test_mode() click to toggle source

Enable test mode inside executors.

# File lib/dh_easy/test.rb, line 11
def self.enable_test_mode
  @@test_mode = true
end
test_mode?() click to toggle source

Check if test mode is enabled inside executors.

@return [Boolean] `true` when test mode enabled, else `false`.

# File lib/dh_easy/test.rb, line 23
def self.test_mode?
  @@test_mode ||= false
end
verbose_log(message, data = nil, log_caller = nil) click to toggle source

Verbose data log within caller backtrace.

@param [String] message Message to display. @param [Object,nil] data (nil) Data to inspect. @param [Array] log_caller (nil) Log caller. Defaults to method caller.

# File lib/dh_easy/test.rb, line 32
def self.verbose_log message, data = nil, log_caller = nil
  log_caller ||= caller
  caller_infos = log_caller.first.split ":"
  text = data.nil? ? 'nil' : JSON.pretty_generate(data)
  puts "\n#{caller_infos[0]}:#{caller_infos[1]} - #{message}#{text}\n\n"
end
verbose_match_diff(type, diff, log_caller = nil) click to toggle source

Verbose a match diff.

@param [Hash] diff Match diff to verbose. @param [Array] log_caller (nil) Log caller. Defaults to method caller.

# File lib/dh_easy/test.rb, line 43
def self.verbose_match_diff type, diff, log_caller = nil
  unless diff[:saved].nil? || diff[:saved].count < 1
    verbose_log "Non matching saved #{type}: ", diff[:saved], log_caller
  end
  unless diff[:expected].nil? || diff[:expected].count < 1
    verbose_log "Non matching expected #{type}: ", diff[:expected], log_caller
  end
end