Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/must.rb
Class Method Summary collapse
Class Method Details
.must(name, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/must.rb', line 9 def self.must(name, &block) # convert "any method description" to any_method_description test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym # don't define a new method if its already defined defined = instance_method(test_name) rescue false raise "#{test_name} is already defined on #{self}" if defined if block_given? # define the actual test_something_is_valid TestCase method # pass it its functionality through a closure block define_method(test_name, &block) else define_method(test_name) do flunk "No implementation provided for #{name}" end end end |