diff options
Diffstat (limited to 'spec/unit/provider/package_spec.rb')
-rw-r--r-- | spec/unit/provider/package_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index c6ec0fb3cb..432d968906 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -704,4 +704,38 @@ describe "Chef::Provider::Package - Multi" do expect(@new_resource).not_to be_updated_by_last_action end end + + describe "shell_out helpers" do + [ :shell_out_with_timeout, :shell_out_with_timeout! ].each do |method| + stubbed_method = method == :shell_out_with_timeout! ? :shell_out! : :shell_out + [ %w{command arg1 arg2}, "command arg1 arg2" ].each do |command| + it "#{method} defaults to 900 seconds" do + expect(@provider).to receive(stubbed_method).with(*command, timeout: 900) + @provider.send(method, *command) + end + it "#{method} overrides the default timeout with its options" do + expect(@provider).to receive(stubbed_method).with(*command, timeout: 1) + @provider.send(method, *command, timeout: 1) + end + it "#{method} overrides both timeouts with the new_resource.timeout" do + @new_resource.timeout(99) + expect(@provider).to receive(stubbed_method).with(*command, timeout: 99) + @provider.send(method, *command, timeout: 1) + end + it "#{method} defaults to 900 seconds and preserves options" do + expect(@provider).to receive(stubbed_method).with(*command, env: nil, timeout: 900) + @provider.send(method, *command, env: nil) + end + it "#{method} overrides the default timeout with its options and preserves options" do + expect(@provider).to receive(stubbed_method).with(*command, timeout: 1, env: nil) + @provider.send(method, *command, timeout: 1, env: nil) + end + it "#{method} overrides both timeouts with the new_resource.timeout and preseves options" do + @new_resource.timeout(99) + expect(@provider).to receive(stubbed_method).with(*command, timeout: 99, env: nil) + @provider.send(method, *command, timeout: 1, env: nil) + end + end + end + end end |