Module: MiniTest::Unit::Deprecated::Hooks
- Included in:
- TestCase
- Defined in:
- lib/minitest/unit.rb
Overview
This entire module is deprecated and slated for removal on 2013-01-01.
Class Method Summary collapse
-
.add_setup_hook(arg = nil, &block) ⇒ Object
Adds a block of code that will be executed before every TestCase is run.
-
.add_teardown_hook(arg = nil, &block) ⇒ Object
Adds a block of code that will be executed after every TestCase is run.
-
.setup_hooks ⇒ Object
:nodoc:.
-
.teardown_hooks ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#_run_hooks(hooks) ⇒ Object
:nodoc:.
-
#run_setup_hooks ⇒ Object
:nodoc:.
-
#run_teardown_hooks ⇒ Object
:nodoc:.
Class Method Details
.add_setup_hook(arg = nil, &block) ⇒ Object
Adds a block of code that will be executed before every TestCase is run.
NOTE: This method is deprecated, use before/after_setup. It will be removed on 2013-01-01.
1110 1111 1112 1113 1114 |
# File 'lib/minitest/unit.rb', line 1110 def self.add_setup_hook arg=nil, &block warn "NOTE: MiniTest::Unit::TestCase.add_setup_hook is deprecated, use before/after_setup via a module (and call super!). It will be removed on 2013-01-01. Called from #{caller.first}" hook = arg || block @setup_hooks << hook end |
.add_teardown_hook(arg = nil, &block) ⇒ Object
Adds a block of code that will be executed after every TestCase is run.
NOTE: This method is deprecated, use before/after_teardown. It will be removed on 2013-01-01.
1145 1146 1147 1148 1149 |
# File 'lib/minitest/unit.rb', line 1145 def self.add_teardown_hook arg=nil, &block warn "NOTE: MiniTest::Unit::TestCase#add_teardown_hook is deprecated, use before/after_teardown. It will be removed on 2013-01-01. Called from #{caller.first}" hook = arg || block @teardown_hooks << hook end |
.setup_hooks ⇒ Object
:nodoc:
1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/minitest/unit.rb', line 1116 def self.setup_hooks # :nodoc: if superclass.respond_to? :setup_hooks then superclass.setup_hooks else [] end + @setup_hooks end |
.teardown_hooks ⇒ Object
:nodoc:
1151 1152 1153 1154 1155 1156 1157 |
# File 'lib/minitest/unit.rb', line 1151 def self.teardown_hooks # :nodoc: if superclass.respond_to? :teardown_hooks then superclass.teardown_hooks else [] end + @teardown_hooks end |
Instance Method Details
#_run_hooks(hooks) ⇒ Object
:nodoc:
1128 1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/minitest/unit.rb', line 1128 def _run_hooks hooks # :nodoc: hooks.each do |hook| if hook.respond_to?(:arity) && hook.arity == 1 hook.call(self) else hook.call end end end |
#run_setup_hooks ⇒ Object
:nodoc:
1124 1125 1126 |
# File 'lib/minitest/unit.rb', line 1124 def run_setup_hooks # :nodoc: _run_hooks self.class.setup_hooks end |
#run_teardown_hooks ⇒ Object
:nodoc:
1159 1160 1161 |
# File 'lib/minitest/unit.rb', line 1159 def run_teardown_hooks # :nodoc: _run_hooks self.class.teardown_hooks.reverse end |