Class: ShellMock::SpawnMonkeyPatch
- Inherits:
-
MonkeyPatch
- Object
- MonkeyPatch
- ShellMock::SpawnMonkeyPatch
- Defined in:
- lib/shell_mock/spawn_monkey_patch.rb
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
- #method_name ⇒ Object
- #override(env, command = nil, **options) ⇒ Object
Instance Method Details
#disable ⇒ Object
39 40 41 42 43 |
# File 'lib/shell_mock/spawn_monkey_patch.rb', line 39 def disable super disable_for(Process.eigenclass) if Process.respond_to?(method_alias, true) end |
#enable ⇒ Object
33 34 35 36 37 |
# File 'lib/shell_mock/spawn_monkey_patch.rb', line 33 def enable enable_for(Process.eigenclass) unless Process.respond_to?(method_alias, true) super end |
#method_name ⇒ Object
7 8 9 |
# File 'lib/shell_mock/spawn_monkey_patch.rb', line 7 def method_name :spawn end |
#override(env, command = nil, **options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/shell_mock/spawn_monkey_patch.rb', line 11 def override(env, command = nil, **) env, command = {}, env if command.nil? # other arg manipulation can go here if necessary stub = StubRegistry.stub_matching(env, command, ) if stub stub.called_with(env, command, ) stub.side_effect.call __un_shell_mocked_spawn(stub.to_oneliner, **) else if ShellMock.let_commands_run? __un_shell_mocked_spawn(env, command, **) else raise NoStubSpecified.new(env, command, ) end end end |