summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-08-02 12:56:56 -0700
committerJohn Keiser <john@johnkeiser.com>2016-08-03 14:16:52 -0700
commitf34d47a1ffc29291c0ea9f544254ccaf0c9db319 (patch)
tree76c40e07287cd0e094b0220206e3e485dfa18857
parent077322211f7971cd81833118863bc28b961ef819 (diff)
downloadchef-f34d47a1ffc29291c0ea9f544254ccaf0c9db319.tar.gz
Fix Chef::Version <=> v to return nil when v is not a Chef::Version
-rw-r--r--lib/chef/version_class.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb
index 35a9f3282f..f018833717 100644
--- a/lib/chef/version_class.rb
+++ b/lib/chef/version_class.rb
@@ -34,8 +34,13 @@ class Chef
def <=>(v)
[:major, :minor, :patch].each do |method|
- ans = (self.send(method) <=> v.send(method))
- return ans if ans != 0
+ version = self.send(method)
+ begin
+ ans = (version <=> v.send(method))
+ rescue NoMethodError # if the other thing isn't a version object, return nil
+ return nil
+ end
+ return ans unless ans == 0
end
0
end