From b1c65734447bf82810897abec96efb8074aa5e60 Mon Sep 17 00:00:00 2001 From: Theodore Nordsieck Date: Thu, 5 Sep 2013 16:08:53 -0700 Subject: Converted plugins/erlang to Mixlib::ShellOut --- lib/ohai/plugins/erlang.rb | 7 +++---- spec/unit/plugins/erlang_spec.rb | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/ohai/plugins/erlang.rb b/lib/ohai/plugins/erlang.rb index 2409a7e1..e398fc61 100644 --- a/lib/ohai/plugins/erlang.rb +++ b/lib/ohai/plugins/erlang.rb @@ -25,10 +25,9 @@ Ohai.plugin do output = nil erlang = Mash.new - status, stdout, stderr = run_command(:no_status_check => true, :command => "erl +V") - - if status == 0 - output = stderr.split + so = shell_out("erl +V") + if so.exitstatus == 0 + output = so.stderr.split if output.length >= 6 options = output[1] options.gsub!(/(\(|\))/, '') diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index d7878788..fc7a2cb1 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -26,14 +26,12 @@ describe Ohai::System, "plugin erlang" do before(:each) do @plugin = get_plugin("erlang") @plugin[:languages] = Mash.new - @status = 0 - @stdin = "" @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n" - @plugin.stub(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr)) end it "should get the erlang version from erl +V" do - @plugin.should_receive(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([0, "", "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"]) + @plugin.should_receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr)) @plugin.run end @@ -56,7 +54,7 @@ describe Ohai::System, "plugin erlang" do @status = 1 @stdin = "" @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n" - @plugin.stub(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(1, "", @stderr)) @plugin.run @plugin.languages.should_not have_key(:erlang) end -- cgit v1.2.1