module FunWith::Testing::TestModeMethods
For adding to a TestCase
class
Public Class Methods
included( base )
click to toggle source
# File lib/fun_with/testing/test_mode_methods.rb, line 5 def self.included( base ) base.extend( TestModeMethods::ClassMethods ) base.send( :include, TestModeMethods::InstanceMethods) end
Public Instance Methods
ClassMethods()
click to toggle source
# File lib/fun_with/testing/test_mode_methods.rb, line 10 def ClassMethods def set_test_mode( mode = true ) self.const_set( :FWT_TEST_MODE, mode ) end # Originally named test_mode?(), but Test::Unit::TestCase picked up on the fact that it started with "test" # and tried to run it as a test in its own right def in_test_mode? return self::FWT_TEST_MODE if self.constants.include?( :FWT_TEST_MODE ) return self.superclass.in_test_mode? if self.superclass.respond_to?(:in_test_mode?) return false end end
InstanceMethods()
click to toggle source
# File lib/fun_with/testing/test_mode_methods.rb, line 24 def InstanceMethods def in_test_mode? self.class.in_test_mode? end end
in_test_mode?()
click to toggle source
Originally named test_mode?(), but Test::Unit::TestCase picked up on the fact that it started with “test” and tried to run it as a test in its own right
# File lib/fun_with/testing/test_mode_methods.rb, line 17 def in_test_mode? return self::FWT_TEST_MODE if self.constants.include?( :FWT_TEST_MODE ) return self.superclass.in_test_mode? if self.superclass.respond_to?(:in_test_mode?) return false end
set_test_mode( mode = true )
click to toggle source
# File lib/fun_with/testing/test_mode_methods.rb, line 11 def set_test_mode( mode = true ) self.const_set( :FWT_TEST_MODE, mode ) end