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.
1152 1153 1154 1155 1156 |
# File 'lib/minitest/unit.rb', line 1152 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.
1187 1188 1189 1190 1191 |
# File 'lib/minitest/unit.rb', line 1187 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:
1158 1159 1160 1161 1162 1163 1164 |
# File 'lib/minitest/unit.rb', line 1158 def self.setup_hooks # :nodoc: if superclass.respond_to? :setup_hooks then superclass.setup_hooks else [] end + @setup_hooks end |
.teardown_hooks ⇒ Object
:nodoc:
1193 1194 1195 1196 1197 1198 1199 |
# File 'lib/minitest/unit.rb', line 1193 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:
1170 1171 1172 1173 1174 1175 1176 1177 1178 |
# File 'lib/minitest/unit.rb', line 1170 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:
1166 1167 1168 |
# File 'lib/minitest/unit.rb', line 1166 def run_setup_hooks # :nodoc: _run_hooks self.class.setup_hooks end |
#run_teardown_hooks ⇒ Object
:nodoc:
1201 1202 1203 |
# File 'lib/minitest/unit.rb', line 1201 def run_teardown_hooks # :nodoc: _run_hooks self.class.teardown_hooks.reverse end |