Module: DhEasy::Test

Defined in:
lib/dh_easy/test.rb,
lib/dh_easy/test/rake.rb,
lib/dh_easy/test/helper.rb,
lib/dh_easy/test/version.rb

Defined Under Namespace

Modules: Helper Classes: RecordTask

Constant Summary collapse

VERSION =

Gem version

"0.0.5"

Class Method Summary collapse

Class Method Details

.disable_test_modeObject

Disable test mode inside executors.



16
17
18
# File 'lib/dh_easy/test.rb', line 16

def self.disable_test_mode
  @@test_mode = false
end

.enable_test_modeObject

Enable test mode inside executors.



11
12
13
# File 'lib/dh_easy/test.rb', line 11

def self.enable_test_mode
  @@test_mode = true
end

.test_mode?Boolean

Check if test mode is enabled inside executors.

Returns:

  • (Boolean)

    ‘true` when test mode enabled, else `false`.



23
24
25
# File 'lib/dh_easy/test.rb', line 23

def self.test_mode?
  @@test_mode ||= false
end

.verbose_log(message, data = nil, log_caller = nil) ⇒ Object

Verbose data log within caller backtrace.

Parameters:

  • message (String)

    Message to display.

  • data (Object, nil) (defaults to: nil)

    (nil) Data to inspect.

  • log_caller (Array) (defaults to: nil)

    (nil) Log caller. Defaults to method caller.



32
33
34
35
36
37
# 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) ⇒ Object

Verbose a match diff.

Parameters:

  • diff (Hash)

    Match diff to verbose.

  • log_caller (Array) (defaults to: nil)

    (nil) Log caller. Defaults to method caller.



43
44
45
46
47
48
49
50
# 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