Module: CoreEx::EmbeddedTests
- Included in:
- Object
- Defined in:
- lib/core_ex/embedded_tests.rb
Constant Summary collapse
- @@embedded_test_mode =
nil
- @@embedded_test_files =
Set.new
- @@embedded_test_blocks =
[]
Instance Method Summary collapse
- #embedded_test_mode(aRegexp) ⇒ Object
- #embedded_test_mode? ⇒ Boolean
- #run_embedded_test_sections ⇒ Object
- #test_section(__file__, &block) ⇒ Object
Instance Method Details
#embedded_test_mode(aRegexp) ⇒ Object
15 16 17 18 19 |
# File 'lib/core_ex/embedded_tests.rb', line 15 def ( aRegexp ) raise 'No block needed' if block_given? require 'test/unit' @@embedded_test_mode = aRegexp end |
#embedded_test_mode? ⇒ Boolean
21 22 23 |
# File 'lib/core_ex/embedded_tests.rb', line 21 def !! @@embedded_test_mode end |
#run_embedded_test_sections ⇒ Object
35 36 37 38 39 |
# File 'lib/core_ex/embedded_tests.rb', line 35 def @@embedded_test_blocks.each do |block| Kernel.instance_eval(&block) end end |
#test_section(__file__, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/core_ex/embedded_tests.rb', line 25 def test_section ( __file__, &block ) __file__ = ::Pathname.new(__file__). if block_given? and __file__.to_s =~ @@embedded_test_mode unless @@embedded_test_files.include?(__file__) @@embedded_test_blocks << block @@embedded_test_files << __file__ end end end |