Module: FunWith::Testing::TestModeMethods
- Defined in:
- lib/fun_with/testing/test_mode_methods.rb
Overview
For adding to a TestCase class
Class Method Summary collapse
Instance Method Summary collapse
- #ClassMethods ⇒ Object
-
#in_test_mode? ⇒ Boolean
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.
- #InstanceMethods ⇒ Object
- #set_test_mode(mode = true) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 |
# 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 |
Instance Method Details
#ClassMethods ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 |
#in_test_mode? ⇒ Boolean
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
17 18 19 20 21 |
# 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 |
#InstanceMethods ⇒ Object
24 25 26 27 28 |
# File 'lib/fun_with/testing/test_mode_methods.rb', line 24 def InstanceMethods def in_test_mode? self.class.in_test_mode? end end |
#set_test_mode(mode = true) ⇒ Object
11 12 13 |
# 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 |