Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/module_ext.rb
Overview
TDD helpers for modules.
Defined Under Namespace
Modules: Reloader
Class Method Summary collapse
-
.by_name(name) ⇒ Object
load a module by name.
Instance Method Summary collapse
-
#etest(*args) ⇒ Object
reloads the module, and runs the module’s etests.
-
#instances ⇒ Object
returns all instances of a module.
- #reload ⇒ Object
- #source_files ⇒ Object
Class Method Details
Instance Method Details
#etest(*args) ⇒ Object
reloads the module, and runs the module’s etests.
15 16 17 18 19 20 |
# File 'lib/module_ext.rb', line 15 def etest(*args) etests = const_get("Etest") modules = [ self, etests ] Reloader.reload *modules ::EtestUnit.run etests, *args end |
#instances ⇒ Object
returns all instances of a module
63 64 65 66 67 |
# File 'lib/module_ext.rb', line 63 def instances #:nodoc: r = [] ObjectSpace.each_object(self) { |mod| r << mod } r end |
#reload ⇒ Object
47 48 49 50 |
# File 'lib/module_ext.rb', line 47 def reload Reloader.reload(self) self end |
#source_files ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/module_ext.rb', line 52 def source_files public_instance_methods(false). map do |method_name| instance_method(method_name) end. map(&:source_location).compact. map(&:first). uniq. sort end |