Sha256: 9e387e05170a1ad76d266032a68cf42f46bab39cbeab8c1f77bff7a966f7cdd9

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require 'shell_mock/monkey_patch'
require 'shell_mock/stub_registry'
require 'shell_mock/no_stub_specified'

module ShellMock
  class SystemMonkeyPatch < MonkeyPatch
    def method_name
      :system
    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.called_with(env, command, options)

        stub.side_effect.call

        __un_shell_mocked_system(stub.to_oneliner)
      else
        if ShellMock.let_commands_run?
          __un_shell_mocked_system(env, command, **options)
        else
          raise NoStubSpecified.new(env, command, options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shell_mock-0.5.0 lib/shell_mock/system_monkey_patch.rb