Module: Mixlib::ShellOut::Helper

Includes:
ChefUtils::DSL::PathSanity, ChefUtils::Internal
Defined in:
lib/mixlib/shellout/helper.rb

Defined Under Namespace

Classes: FakeShellOut

Instance Method Summary collapse

Instance Method Details

#shell_out(*args, **options) ⇒ Object

PREFERRED APIS:

all consumers should now call shell_out!/shell_out.

the shell_out_compacted/shell_out_compacted! APIs are private but are intended for use in rspec tests, and should ideally always be used to make code refactoring that do not change behavior easier:

allow(provider).to receive(:shell_out_compacted!).with(“foo”, “bar”, “baz”) provider.shell_out!(“foo”, [ “bar”, nil, “baz”]) provider.shell_out!([“foo”, nil, “bar” ], [“baz”])

note that shell_out_compacted also includes adding the magical timeout option to force people to setup expectations on that value explicitly. it does not include the default_env mangling in order to avoid users having to setup an expectation on anything other than setting ‘default_env: false` and allow us to make tweak to the default_env without breaking a thousand unit tests.



48
49
50
51
52
53
54
55
56
# File 'lib/mixlib/shellout/helper.rb', line 48

def shell_out(*args, **options)
  options = options.dup
  options = __maybe_add_timeout(self, options)
  if options.empty?
    shell_out_compacted(*__clean_array(*args))
  else
    shell_out_compacted(*__clean_array(*args), **options)
  end
end

#shell_out!(*args, **options) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/mixlib/shellout/helper.rb', line 58

def shell_out!(*args, **options)
  options = options.dup
  options = __maybe_add_timeout(self, options)
  if options.empty?
    shell_out_compacted!(*__clean_array(*args))
  else
    shell_out_compacted!(*__clean_array(*args), **options)
  end
end