diff options
author | joe.nuspl <joe.nuspl@workday.com> | 2014-09-10 14:57:08 -0700 |
---|---|---|
committer | joe.nuspl <joe.nuspl@workday.com> | 2014-09-10 14:57:08 -0700 |
commit | 44f84623c412ff586ec60b366e08f1c253c35cb3 (patch) | |
tree | 8c07d6d5b037ab8520e67a3ceccefdc2b357ee01 /spec/unit/provider | |
parent | 13d328cd109740c60a2e633d13c6b1016c405d6e (diff) | |
download | chef-44f84623c412ff586ec60b366e08f1c253c35cb3.tar.gz |
Factored out opts into before clause.
Change-Id: I1d9e384187c2f7762598c41598cddd35ce9171be
Diffstat (limited to 'spec/unit/provider')
-rw-r--r-- | spec/unit/provider/execute_spec.rb | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index ba51d4d6c6..4d2973ba7d 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -34,18 +34,19 @@ describe Chef::Provider::Execute do Chef::Log.level = :info # FIXME: There should be a test for how STDOUT.tty? changes the live_stream option being passed STDOUT.stub(:tty?).and_return(true) - end + @opts = { + timeout: @new_resource.timeout, + returns: @new_resource.returns, + log_level: :info, + log_tag: @new_resource.to_s, + live_stream: STDOUT + } + end it "should execute foo_resource" do @provider.stub(:load_current_resource) - opts = {} - opts[:timeout] = @new_resource.timeout - opts[:returns] = @new_resource.returns - opts[:log_level] = :info - opts[:log_tag] = @new_resource.to_s - opts[:live_stream] = STDOUT - @provider.should_receive(:shell_out!).with(@new_resource.command, opts) + @provider.should_receive(:shell_out!).with(@new_resource.command, @opts) @provider.should_receive(:converge_by).with("execute foo_resource").and_call_original Chef::Log.should_not_receive(:warn) @@ -57,14 +58,8 @@ describe Chef::Provider::Execute do @new_resource.sensitive true @provider = Chef::Provider::Execute.new(@new_resource, @run_context) @provider.stub(:load_current_resource) - opts = {} - opts[:timeout] = @new_resource.timeout - opts[:returns] = @new_resource.returns - opts[:log_level] = :info - opts[:log_tag] = @new_resource.to_s # Since the resource is sensitive, it should not have :live_stream set - # opts[:live_stream] = STDOUT - @provider.should_receive(:shell_out!).with(@new_resource.command, opts) + @provider.should_receive(:shell_out!).with(@new_resource.command, @opts.reject { |k| k == :live_stream }) Chef::Log.should_not_receive(:warn) @provider.should_receive(:converge_by).with("execute sensitive resource").and_call_original @provider.run_action(:run) |