diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-09-27 17:15:16 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-09-27 17:15:16 -0700 |
commit | 6f3e016a093982816301fe65b0b63ad3d92953cb (patch) | |
tree | 09b1fb8c0c0696bdd2342e466e83ce82480394d8 /spec | |
parent | 32edd6dcfb8becf186709a19f5ce9adc44881b26 (diff) | |
download | chef-6f3e016a093982816301fe65b0b63ad3d92953cb.tar.gz |
sanitize inputs to Gem::Versionlcg/gem-version-sanitization
we know this may produce incorrect comparisons in some cases, but
we never want it to fail.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index 688d70d677..36b282c6ac 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -980,4 +980,26 @@ describe "Chef::Provider::Package - Multi" do end end end + + describe "version_compare" do + it "tests equality" do + expect(provider.version_compare("1.3", "1.3")).to eql(0) + end + + it "tests less than" do + expect(provider.version_compare("1.2", "1.3")).to eql(-1) + end + + it "tests greater than" do + expect(provider.version_compare("1.5", "1.3")).to eql(1) + end + + it "x.10 is greater than x.2 (so does not do floating point comparisons)" do + expect(provider.version_compare("1.10", "1.2")).to eql(1) + end + + it "sanitizes inputs" do + expect(provider.version_compare("1.3_3", "1.3")).to eql(0) + end + end end |