Sha256: 7da2a15ad3e199f265614d8be4bd285f535c227867079e7eb607dd9e014c7a2f
Contents?: true
Size: 1007 Bytes
Versions: 2
Compression:
Stored size: 1007 Bytes
Contents
require 'shell_mock/monkey_patch' require 'shell_mock/stub_registry' require 'shell_mock/no_stub_specified' module ShellMock class SpawnMonkeyPatch < MonkeyPatch def method_name :spawn end def override(env, command = nil, **options) env, command = {}, env if command.nil? # other arg manipulation can go here if necessary stub = StubRegistry.stub_matching(env, command, options) if stub stub.ran stub.side_effect.call __un_shell_mocked_spawn(stub.to_oneliner, **options) else if ShellMock.let_commands_run? __un_shell_mocked_spawn(env, command, **options) else raise NoStubSpecified.new(env, command, options) end end end def enable enable_for(Process.eigenclass) unless Process.respond_to?(method_alias, true) super end def disable super disable_for(Process.eigenclass) if Process.respond_to?(method_alias, true) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shell_mock-0.7.0 | lib/shell_mock/spawn_monkey_patch.rb |
shell_mock-0.6.0 | lib/shell_mock/spawn_monkey_patch.rb |