diff options
author | Bryan McLellan <btm@loftninjas.org> | 2017-11-22 13:25:18 -0500 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2017-11-22 13:42:02 -0500 |
commit | cef9ea636ab110b24b5703cce1455db69706d6be (patch) | |
tree | dc861cfed42bd41f3115ea861179d64bd90eae61 | |
parent | 7430c834fb1a95a724d14da528b75a7e07dfe6ca (diff) | |
download | chef-cef9ea636ab110b24b5703cce1455db69706d6be.tar.gz |
Stub out call to 'ifconfig --version' in unit tests
A recent change to the ifconfig provider added a new shellout call without
a corresponding stub added to the unit tests.
Signed-off-by: Bryan McLellan <btm@loftninjas.org>
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/ifconfig_spec.rb | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index cdca0db10b..5008d7877a 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -78,7 +78,7 @@ class Chef # TX packets:41723949 errors:0 dropped:0 overruns:0 carrier:0 # collisions:0 txqueuelen:1000 # RX bytes:42664658792 (39.7 GiB) TX bytes:52722603938 (49.1 GiB) - # Interrupt:30 + # Interrupt:30 @status = shell_out("ifconfig") @status.stdout.each_line do |line| if !line[0..9].strip.empty? diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index da27d647ee..3732d75cc9 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -38,12 +38,19 @@ describe Chef::Provider::Ifconfig do status = double("Status", exitstatus: 0) @provider.instance_variable_set("@status", status) @provider.current_resource = @current_resource - end + describe Chef::Provider::Ifconfig, "load_current_resource" do + let(:net_tools_version) { StringIO.new <<-EOS } +net-tools 1.60 +ifconfig 1.42 (2001-04-13) +EOS + before do - @status = double(stdout: "", exitstatus: 1) - allow(@provider).to receive(:shell_out).and_return(@status) + ifconfig = double(stdout: "", exitstatus: 1) + allow(@provider).to receive(:shell_out).and_return(ifconfig) + ifconfig_version = double(stdout: "", stderr: net_tools_version, exitstatus: 4) + allow(@provider).to receive(:shell_out).with("ifconfig --version").and_return(ifconfig_version) @provider.load_current_resource end it "should track state of ifconfig failure" do |