Method: Modulation.mock
- Defined in:
- lib/modulation/core.rb
.mock(path, mod, caller_location = caller(CALLER_RANGE).first) ⇒ void
This method returns an undefined value.
Maps the given path to the given mock module, restoring the previously loaded module (if any) after calling the given block
158 159 160 161 162 163 164 165 |
# File 'lib/modulation/core.rb', line 158 def mock(path, mod, caller_location = caller(CALLER_RANGE).first) path = Paths.absolute_path(path, caller_location) old_module = @loaded_modules[path] @loaded_modules[path] = mod yield if block_given? ensure @loaded_modules[path] = old_module if block_given? end |