diff options
| -rw-r--r-- | lib/chef/node_map.rb | 2 | ||||
| -rw-r--r-- | spec/unit/node_map_spec.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index 7a1a09ae24..25b1f57d44 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -143,7 +143,7 @@ class Chef filter_values.empty? || Array(filter_values).any? do |v| - Chef::VersionConstraint::Platform.new(v).include?(value) + Gem::Requirement.new(v).satisfied_by?(Gem::Version.new(value)) end end diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 822f689eab..64106323c2 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -101,6 +101,24 @@ describe Chef::NodeMap do end end + describe "platform version checks" do + before do + node_map.set(:thing, :foo, platform_family: "rhel", platform_version: ">= 7") + end + + it "handles non-x.y.z platform versions without throwing an exception" do + allow(node).to receive(:[]).with(:platform_family).and_return("rhel") + allow(node).to receive(:[]).with(:platform_version).and_return("7.19.2.2F") + expect(node_map.get(node, :thing)).to eql(:foo) + end + + it "handles non-x.y.z platform versions without throwing an exception when the match fails" do + allow(node).to receive(:[]).with(:platform_family).and_return("rhel") + allow(node).to receive(:[]).with(:platform_version).and_return("4.19.2.2F") + expect(node_map.get(node, :thing)).to eql(nil) + end + end + describe "with a block doing platform_version checks" do before do node_map.set(:thing, :foo, platform_family: "rhel") do |node| |
