summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Morhovich <dmorhovich@pivotal.io>2015-10-27 12:16:36 -0400
committerJT Archie <jtarchie@gmail.com>2015-10-27 14:01:57 -0400
commitb4a52c3b29423d3f41c956f638c92ab9830e2716 (patch)
treed2b6bfb3237c9c44c075b7dfc378b5bf6c0cb25c /spec
parentb53dda5d06164e4016f1243d64c12fbb17b33770 (diff)
downloadbundler-b4a52c3b29423d3f41c956f638c92ab9830e2716.tar.gz
Adds ruby version to Gemfile.lock.
* Adds support for `bundle update --ruby` command to allow for updating ruby version in Gemfile.lock. * Adds support for `bundle install` to allow for adding ruby version in Gemfile.lock. https://www.pivotaltracker.com/story/show/106008092 Signed-off-by: JT Archie <jtarchie@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/install_spec.rb66
-rw-r--r--spec/commands/update_spec.rb119
-rw-r--r--spec/lock/lockfile_spec.rb27
-rw-r--r--spec/resolver/basic_spec.rb2
4 files changed, 213 insertions, 1 deletions
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index 5132e4cffb..07fa2db836 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -340,6 +340,72 @@ describe "bundle install with gem sources" do
end
end
+ describe "Ruby version in Gemfile.lock" do
+ include Bundler::GemHelpers
+
+ context "and using an unsupported Ruby version" do
+ it "prints an error" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '1.8.7'
+ ruby '~> 2.1'
+ G
+ expect(out).to include("Your Ruby version is 1.8.7, but your Gemfile specified ~> 2.1")
+ end
+ end
+
+ context "and using a supported Ruby version" do
+ before do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+ end
+
+ it "writes current Ruby version to Gemfile.lock" do
+ lockfile_should_be <<-L
+ GEM
+ specs:
+
+ PLATFORMS
+ ruby
+
+ RUBY VERSION
+ ruby 2.1.3p100
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
+ it "does not update Gemfile.lock with updated ruby versions" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.2.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.2.0'
+ G
+
+ lockfile_should_be <<-L
+ GEM
+ specs:
+
+ PLATFORMS
+ ruby
+
+ RUBY VERSION
+ ruby 2.1.3p100
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+ end
+
describe "when Bundler root contains regex chars" do
before do
root_dir = tmp("foo[]bar")
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 0ea721d738..18a9289d69 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -319,3 +319,122 @@ describe "bundle update" do
expect(exitstatus).to eq(22) if exitstatus
end
end
+
+describe "bundle update --ruby" do
+ context "when the Gemfile removes the ruby" do
+ it "removes the Ruby from the Gemfile.lock" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.4'
+ ::RUBY_PATCHLEVEL = 222
+ G
+
+ bundle "update --ruby"
+
+ lockfile_should_be <<-L
+ GEM
+ specs:
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+
+ context "when the Gemfile specified an updated Ruby verison" do
+ it "updates the Gemfile.lock with the latest version" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.4'
+ ::RUBY_PATCHLEVEL = 222
+ ruby '~> 2.1.0'
+ G
+
+ bundle "update --ruby"
+
+ lockfile_should_be <<-L
+ GEM
+ specs:
+
+ PLATFORMS
+ ruby
+
+ RUBY VERSION
+ ruby 2.1.4p222
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+
+ context "when a different Ruby is being used than has been versioned" do
+ it "shows a helpful error message" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.2.2'
+ ::RUBY_PATCHLEVEL = 505
+ ruby '~> 2.1.0'
+ G
+
+ bundle "update --ruby"
+ expect(out).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
+ end
+ end
+
+ context "when updating Ruby version and Gemfile `ruby`" do
+ it "updates the Gemfile.lock with the latest version" do
+ install_gemfile <<-G
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+
+ install_gemfile <<-G
+ ::RUBY_VERSION = '1.8.3'
+ ::RUBY_PATCHLEVEL = 55
+ ruby '~> 1.8.0'
+ G
+
+ bundle "update --ruby"
+
+ lockfile_should_be <<-L
+ GEM
+ specs:
+
+ PLATFORMS
+ ruby
+
+ RUBY VERSION
+ ruby 1.8.3p55
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index bcca03983c..3776cd2070 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -1124,6 +1124,33 @@ describe "the lockfile format" do
G
end
+ it "captures the Ruby version in the lockfile", :focus do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ ruby '#{RUBY_VERSION}'
+ gem "rack", "> 0.9", "< 1.0"
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ rack (0.9.1)
+
+ PLATFORMS
+ ruby
+
+ RUBY VERSION
+ ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
+
+ DEPENDENCIES
+ rack (> 0.9, < 1.0)
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
# Some versions of the Bundler 1.1 RC series introduced corrupted
# lockfiles. There were two major problems:
#
diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb
index 416f94d4c5..f13756ea24 100644
--- a/spec/resolver/basic_spec.rb
+++ b/spec/resolver/basic_spec.rb
@@ -99,7 +99,7 @@ describe "Resolving" do
deps << Bundler::DepProxy.new(d, "ruby")
end
- got = Bundler::Resolver.resolve(deps, @index, {}, [], "1.8.7")
+ got = Bundler::Resolver.resolve(deps, @index, {}, [], Bundler::RubyVersionRequirement.new("1.8.7", nil, nil, nil))
got = got.map(&:full_name).sort
expect(got).to eq(%w(foo-1.0.0 bar-1.0.0).sort)
end