Module: TestUnitExtend
- Included in:
- ActiveSupport::TestCase, ActiveSupport::TestCase, Test::Unit::TestCase, Test::Unit::TestCase
- Defined in:
- lib/before_test.rb,
lib/should_have_callbacks.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/before_test.rb', line 2 def self.included(base) def run(result,&block) send(@@___before_tests[method_name]) if @@___before_tests[method_name] original_run(result,&block) end class << base @@___before_tests ||= {} def before_test test, proc @@___before_tests.merge!({test.to_s => proc}) end end end |
Instance Method Details
#run(result, &block) ⇒ Object
4 5 6 7 |
# File 'lib/before_test.rb', line 4 def run(result,&block) send(@@___before_tests[method_name]) if @@___before_tests[method_name] original_run(result,&block) end |
#should_have_callbacks(callback, methods) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/should_have_callbacks.rb', line 5 def should_have_callbacks callback, methods klass = self.name.gsub('Test', '').constantize chain = callback.to_s + '_callback_chain' callbacks = klass.send(chain).map{|callback| callback.instance_variable_get(:@method)} self.send(:define_method, :test_XXX_callbacks) do assert ([*methods] - callbacks).empty? end end |