summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian C. Dunn <jdunn@chef.io>2015-07-04 21:11:26 -0700
committerJulian C. Dunn <jdunn@chef.io>2015-07-04 21:11:53 -0700
commitc55c392c7f517b1582e8470d516406b07b14a7e2 (patch)
tree145a2e0858ef29a05a40d3d8fe3ec48da31ce3c9
parenta7d9433b5e25fa79aff77834e303ade47ff02738 (diff)
downloadchef-c55c392c7f517b1582e8470d516406b07b14a7e2.tar.gz
Add tests per review.
-rw-r--r--spec/unit/provider/ifconfig_spec.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index d290ab7066..4940f19a45 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::Ifconfig do
allow(@provider).to receive(:shell_out).and_return(@status)
@provider.load_current_resource
end
- it "should track state of ifconfig failure." do
+ it "should track state of ifconfig failure" do
expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0)
end
it "should thrown an exception when ifconfig fails" do
@@ -68,6 +68,16 @@ describe Chef::Provider::Ifconfig do
expect(@new_resource).to be_updated
end
+ it "should set the address to target if specified" do
+ allow(@provider).to receive(:load_current_resource)
+ @new_resource.target "172.16.32.2"
+ command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
+ expect(@provider).to receive(:run_command).with(:command => command)
+
+ @provider.run_action(:add)
+ expect(@new_resource).to be_updated
+ end
+
it "should not add an interface if it already exists" do
allow(@provider).to receive(:load_current_resource)
expect(@provider).not_to receive(:run_command)
@@ -85,7 +95,7 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_enable" do
- it "should enable interface if does not exist" do
+ it "should enable interface if it does not exist" do
allow(@provider).to receive(:load_current_resource)
@current_resource.inet_addr nil
command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
@@ -96,6 +106,16 @@ describe Chef::Provider::Ifconfig do
expect(@new_resource).to be_updated
end
+ it "should set the address to target if specified" do
+ allow(@provider).to receive(:load_current_resource)
+ @new_resource.target "172.16.32.2"
+ command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
+ expect(@provider).to receive(:run_command).with(:command => command)
+
+ @provider.run_action(:enable)
+ expect(@new_resource).to be_updated
+ end
+
it "should not enable interface if it already exists" do
allow(@provider).to receive(:load_current_resource)
expect(@provider).not_to receive(:run_command)