Module: IfTest

Defined in:
lib/el4r/el4r-sub.rb

Overview

W3MUtils depend: w3m iftest Test mode. Returns a temporary value when unit-testing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#test_modeObject Also known as: test_mode?

Set true when unit-testing.



445
446
447
# File 'lib/el4r/el4r-sub.rb', line 445

def test_mode
  @test_mode
end

Instance Method Details

#if_test(test_value, non_test_value = nil, &block) ⇒ Object

Returns a temporary value when unit-testing.



450
451
452
453
454
455
456
457
458
459
460
# File 'lib/el4r/el4r-sub.rb', line 450

def if_test(test_value, non_test_value=nil, &block)
  if self.test_mode?
    test_value
  else
    if block
      block.call
    else
      non_test_value
    end
  end
end