diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-04-24 14:04:41 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-26 13:37:50 -0700 |
commit | f5b57c72551fa6816383dae2fb7497272f2b5c58 (patch) | |
tree | 05c178ed97909545073af75a42a65d70ae22c60a | |
parent | 8ba60847b60ee312a99df4b7f992d9801fbf9aee (diff) | |
download | ohai-f5b57c72551fa6816383dae2fb7497272f2b5c58.tar.gz |
fix specs
-rw-r--r-- | spec/unit/plugins/python_spec.rb | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index 85892fc2..f8fddba7 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,29 +21,35 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin python" do + let(:stdout) { "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" } + + let(:retval) { 0 } + + let(:plugin) do + plugin = get_plugin("python") + plugin[:languages] = Mash.new + plugin.should_receive(:shell_out).with("python -c \"import sys; print (sys.version)\"").and_return(mock_shell_out(retval, stdout, "")) + plugin + end before(:each) do - @plugin = get_plugin("python") - @plugin[:languages] = Mash.new - @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" - @plugin.stub(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, "")) end - + it "should get the python version from printing sys.version and sys.platform" do - @plugin.should_receive(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + plugin.run end it "should set languages[:python][:version]" do - @plugin.run - @plugin.languages[:python][:version].should eql("2.5.2") - end - - it "should not set the languages[:python] tree up if python command fails" do - @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" - @plugin.stub(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(1, @stdout, "")) - @plugin.run - @plugin.languages.should_not have_key(:python) + plugin.run + plugin.languages[:python][:version].should eql("2.5.2") end + context "when the python command fails" do + let(:retval) { 1 } + + it "should not set the languages[:python] tree up" do + plugin.run + plugin.languages.should_not have_key(:python) + end + end end |