summaryrefslogtreecommitdiff
path: root/spec
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
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')
-rw-r--r--spec/bundler/ruby_version_spec.rb80
-rw-r--r--spec/other/platform_spec.rb26
2 files changed, 80 insertions, 26 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
diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb
index f36cf527ec..d1c1cb49ed 100644
--- a/spec/other/platform_spec.rb
+++ b/spec/other/platform_spec.rb
@@ -203,7 +203,6 @@ G
let(:engine_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{RUBY_VERSION}\"" }
let(:engine_version_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" }
let(:patchlevel_incorrect) { "#{ruby_version_correct}, :patchlevel => '#{not_local_patchlevel}'" }
- let(:patchlevel_fixnum) { "#{ruby_version_correct}, :patchlevel => #{RUBY_PATCHLEVEL}1" }
def should_be_ruby_version_incorrect
expect(exitstatus).to eq(18) if exitstatus
@@ -225,11 +224,6 @@ G
expect(out).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}")
end
- def should_be_patchlevel_fixnum
- expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("The Ruby patchlevel in your Gemfile must be a string")
- end
-
context "bundle install" do
it "installs fine when the ruby version matches" do
install_gemfile <<-G
@@ -1225,25 +1219,5 @@ G
should_be_patchlevel_incorrect
end
end
-
- it "fails when the patchlevel is a fixnum" do
- simulate_ruby_engine "jruby" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "file://#{gem_repo2}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{patchlevel_fixnum}
- G
-
- bundle "outdated"
- should_be_patchlevel_fixnum
- end
- end
end
end