summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-02-01 11:49:53 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-02-01 15:45:25 -0600
commit0d171a7a1ac47ee9df7b735c2d7e9d396168dea3 (patch)
tree19eb0f5b5a8f7676cb23195de8309ea978acad24
parentc323e2e555d0c6eefca9bc1648ae2806356370c4 (diff)
downloadbundler-0d171a7a1ac47ee9df7b735c2d7e9d396168dea3.tar.gz
[RubyVersion] Add specs for multiple requirements
-rw-r--r--spec/bundler/ruby_version_spec.rb77
1 files changed, 77 insertions, 0 deletions
diff --git a/spec/bundler/ruby_version_spec.rb b/spec/bundler/ruby_version_spec.rb
index eeaf0bf294..ce68463029 100644
--- a/spec/bundler/ruby_version_spec.rb
+++ b/spec/bundler/ruby_version_spec.rb
@@ -34,6 +34,27 @@ describe "Bundler::RubyVersion and its subclasses" do
expect(subject.engine_versions).to eq(["2.0.0"])
end
end
+
+ context "is called with multiple requirements" do
+ let(:version) { ["<= 2.0.0", "> 1.9.3"] }
+ let(:engine_version) { nil }
+
+ it "sets the versions" do
+ expect(subject.versions).to eq(version)
+ end
+
+ it "sets the engine versions" do
+ expect(subject.engine_versions).to eq(version)
+ end
+ end
+
+ context "is called with multiple engine requirements" do
+ let(:engine_version) { [">= 2.0", "< 2.3"] }
+
+ it "sets the engine versions" do
+ expect(subject.engine_versions).to eq(engine_version)
+ end
+ end
end
describe "#to_s" do
it "should return info string with the ruby version, patchlevel, engine, and engine version" do
@@ -55,6 +76,16 @@ describe "Bundler::RubyVersion and its subclasses" do
expect(subject.to_s).to eq("ruby 2.0.0p645")
end
end
+
+ context "with multiple requirements" do
+ let(:engine_version) { ["> 9", "< 11"] }
+ let(:version) { ["> 8", "< 10"] }
+ let(:patchlevel) { nil }
+
+ it "should return info string with all requirements" do
+ expect(subject.to_s).to eq("ruby > 8, < 10 (jruby > 9, < 11)")
+ end
+ end
end
describe "#==" do
@@ -131,6 +162,7 @@ describe "Bundler::RubyVersion and its subclasses" do
it_behaves_like "it parses the version from the requirement string", "~> 2.0.0"
it_behaves_like "it parses the version from the requirement string", "< 2.0.0"
it_behaves_like "it parses the version from the requirement string", "= 2.0.0"
+ it_behaves_like "it parses the version from the requirement string", ["> 2.0.0", "< 2.4.5"]
end
describe "#diff" do
@@ -187,6 +219,16 @@ describe "Bundler::RubyVersion and its subclasses" do
it_behaves_like "there is a difference in the versions"
end
+ context "detects version discrepancies with multiple requirements second" do
+ let(:other_version) { "2.0.1" }
+ let(:other_patchlevel) { "643" }
+ let(:other_engine_version) { "2.0.0" }
+
+ let(:version) { ["> 2.0.0", "< 1.0.0"] }
+
+ it_behaves_like "there is a difference in the versions"
+ end
+
context "detects engine version discrepancies third" do
let(:other_patchlevel) { "643" }
let(:other_engine_version) { "2.0.0" }
@@ -194,6 +236,15 @@ describe "Bundler::RubyVersion and its subclasses" do
it_behaves_like "there is a difference in the engine versions"
end
+ context "detects engine version discrepancies with multiple requirements third" do
+ let(:other_patchlevel) { "643" }
+ let(:other_engine_version) { "2.0.0" }
+
+ let(:engine_version) { ["> 2.0.0", "< 1.0.0"] }
+
+ it_behaves_like "there is a difference in the engine versions"
+ end
+
context "detects patchlevel discrepancies last" do
let(:other_patchlevel) { "643" }
@@ -213,6 +264,32 @@ describe "Bundler::RubyVersion and its subclasses" do
it_behaves_like "there are no differences"
end
+ context "successfully matches multiple gem requirements" do
+ let(:version) { [">= 2.0.0", "< 2.4.5"] }
+ let(:patchlevel) { "< 643" }
+ let(:engine) { "ruby" }
+ let(:engine_version) { ["~> 2.0.1", "< 2.4.5"] }
+ let(:other_version) { "2.0.0" }
+ let(:other_patchlevel) { "642" }
+ let(:other_engine) { "ruby" }
+ let(:other_engine_version) { "2.0.5" }
+
+ it_behaves_like "there are no differences"
+ end
+
+ context "successfully detects bad gem requirements with versions with multiple requirements" do
+ let(:version) { ["~> 2.0.0", "< 2.0.5"] }
+ let(:patchlevel) { "< 643" }
+ let(:engine) { "ruby" }
+ let(:engine_version) { "~> 2.0.1" }
+ let(:other_version) { "2.0.5" }
+ let(:other_patchlevel) { "642" }
+ let(:other_engine) { "ruby" }
+ let(:other_engine_version) { "2.0.5" }
+
+ it_behaves_like "there is a difference in the versions"
+ end
+
context "successfully detects bad gem requirements with versions" do
let(:version) { "~> 2.0.0" }
let(:patchlevel) { "< 643" }