summaryrefslogtreecommitdiff
path: root/spec/bundler/ruby_version_spec.rb
diff options
context:
space:
mode:
authorJT Archie <jtarchie@gmail.com>2015-10-20 09:48:36 -0400
committerDavid Morhovich <dmorhovich@pivotal.io>2015-10-20 09:48:36 -0400
commitb53dda5d06164e4016f1243d64c12fbb17b33770 (patch)
treed5f2bfa7f077cbc1573819a96c63931d9a8c0e64 /spec/bundler/ruby_version_spec.rb
parent282930e09cc4bac1b0f53244d8ec4e9c8caaa197 (diff)
parent2c8dd13c5617e402caebc0c113abc53cf8f4df58 (diff)
downloadbundler-b53dda5d06164e4016f1243d64c12fbb17b33770.tar.gz
Merge remote-tracking branch 'version/master'
Signed-off-by: David Morhovich <dmorhovich@pivotal.io>
Diffstat (limited to 'spec/bundler/ruby_version_spec.rb')
-rw-r--r--spec/bundler/ruby_version_spec.rb80
1 files changed, 80 insertions, 0 deletions
diff --git a/spec/bundler/ruby_version_spec.rb b/spec/bundler/ruby_version_spec.rb
new file mode 100644
index 0000000000..2fb7956047
--- /dev/null
+++ b/spec/bundler/ruby_version_spec.rb
@@ -0,0 +1,80 @@
+require "spec_helper"
+require "bundler/ruby_version"
+
+describe Bundler::RubyVersion do
+ def requirement(version, patchlevel = nil, engine = nil, engine_version = nil)
+ Bundler::RubyVersionRequirement.new(
+ version, patchlevel, engine, engine_version)
+ end
+
+ def version(version, patchlevel = nil, engine = nil, engine_version = nil)
+ Bundler::RubyVersion.new(version, patchlevel, engine, engine_version)
+ end
+
+ it "matches simple version requirements" do
+ expect(requirement("2.0.0").diff(version("2.0.0"))).to be_nil
+ end
+
+ it "matches simple patchlevel requirements" do
+ req = requirement("2.0.0", "645")
+ ver = version("2.0.0", "645")
+
+ expect(req.diff(ver)).to be_nil
+ end
+
+ it "matches engine" do
+ req = requirement("2.0.0", "645", "ruby")
+ ver = version("2.0.0", "645", "ruby")
+
+ expect(req.diff(ver)).to be_nil
+ end
+
+ it "matches simple engine version requirements" do
+ req = requirement("2.0.0", "645", "ruby", "2.0.1")
+ ver = version("2.0.0", "645", "ruby", "2.0.1")
+
+ expect(req.diff(ver)).to be_nil
+ end
+
+ it "detects engine discrepancies first" do
+ req = requirement("2.0.0", "645", "ruby", "2.0.1")
+ ver = requirement("2.0.1", "643", "rbx", "2.0.0")
+
+ expect(req.diff(ver)).to eq([:engine, "ruby", "rbx"])
+ end
+
+ it "detects version discrepancies second" do
+ req = requirement("2.0.0", "645", "ruby", "2.0.1")
+ ver = requirement("2.0.1", "643", "ruby", "2.0.0")
+
+ expect(req.diff(ver)).to eq([:version, "2.0.0", "2.0.1"])
+ end
+
+ it "detects engine version discrepancies third" do
+ req = requirement("2.0.0", "645", "ruby", "2.0.1")
+ ver = requirement("2.0.0", "643", "ruby", "2.0.0")
+
+ expect(req.diff(ver)).to eq([:engine_version, "2.0.1", "2.0.0"])
+ end
+
+ it "detects patchlevel discrepancies last" do
+ req = requirement("2.0.0", "645", "ruby", "2.0.1")
+ ver = requirement("2.0.0", "643", "ruby", "2.0.1")
+
+ expect(req.diff(ver)).to eq([:patchlevel, "645", "643"])
+ end
+
+ it "successfully matches gem requirements" do
+ req = requirement(">= 2.0.0", "< 643", "ruby", "~> 2.0.1")
+ ver = version("2.0.0", "642", "ruby", "2.0.5")
+
+ expect(req.diff(ver)).to be_nil
+ end
+
+ it "successfully detects bad gem requirements" do
+ req = requirement(">= 2.0.0", "< 643", "ruby", "~> 2.0.1")
+ ver = version("2.0.0", "642", "ruby", "2.1.0")
+
+ expect(req.diff(ver)).to eq([:engine_version, "~> 2.0.1", "2.1.0"])
+ end
+end