diff options
-rw-r--r-- | lib/chef/node_map.rb | 2 | ||||
-rw-r--r-- | spec/unit/node_map_spec.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index d5eed7c215..edf0fd689a 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -181,7 +181,7 @@ class Chef end def compare_matchers(key, new_matcher, matcher) - cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:filters][:block] } + cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:block] } return cmp if cmp != 0 cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:filters][:platform_version] } return cmp if cmp != 0 diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 9b5ff5e8c6..7b37ea59f4 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -131,6 +131,18 @@ describe Chef::NodeMap do allow(node).to receive(:[]).with(:platform_version).and_return("6.0") expect(node_map.get(node, :thing)).to eql(nil) end + + context "when there is a less specific definition" do + before do + node_map.set(:thing, :bar, platform_family: "rhel") + end + + it "returns the value when the node matches" do + allow(node).to receive(:[]).with(:platform_family).and_return("rhel") + allow(node).to receive(:[]).with(:platform_version).and_return("7.0") + expect(node_map.get(node, :thing)).to eql(:foo) + end + end end describe "resource back-compat testing" do |