summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Walck <nate.walck@gmail.com>2016-02-01 21:17:30 -0800
committerNate Walck <nate.walck@gmail.com>2016-02-02 14:12:59 -0800
commit4d3c45b37c66d20b3799551e99a8dcd9fa3228c4 (patch)
tree710c7dc119f5382c791ecd8e3488499c7fd16a2c
parent5536dd9e73159e3eff1b42be79f46d6f0540c4a1 (diff)
downloadchef-4d3c45b37c66d20b3799551e99a8dcd9fa3228c4.tar.gz
Bad test lead to a provider coverage failure for brand new machines with no profiles installed
-rw-r--r--lib/chef/provider/osx_profile.rb11
-rw-r--r--spec/unit/provider/osx_profile_spec.rb2
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index 071b4b0462..dccda49e1d 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -54,10 +54,13 @@ class Chef
@new_resource.profile_name
end
- current_profile = all_profiles["_computerlevel"].find {
- |item| item["ProfileIdentifier"] ==
- @new_profile_identifier
- }
+ if all_profiles.empty?
+ current_profile = nil
+ else
+ current_profile = all_profiles["_computerlevel"].find do |item|
+ item["ProfileIdentifier"] == @new_profile_identifier
+ end
+ end
@current_resource.profile(current_profile)
end
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index 76bfc3b4eb..f1e16d08db 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -106,7 +106,7 @@ describe Chef::Provider::OsxProfile do
}
end
let(:no_profiles) do
- { "_computerlevel"=> [] }
+ { }
end
before(:each) do