summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--Rakefile2
-rw-r--r--lib/bundler.rb67
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/update.rb4
-rw-r--r--lib/bundler/definition.rb37
-rw-r--r--lib/bundler/lockfile_parser.rb9
-rw-r--r--lib/bundler/resolver.rb4
-rw-r--r--lib/bundler/ruby_dsl.rb2
-rw-r--r--lib/bundler/ruby_version.rb87
-rw-r--r--lib/bundler/templates/newgem/.travis.yml.tt1
-rw-r--r--spec/bundler/ruby_version_spec.rb80
-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
16 files changed, 446 insertions, 66 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40e28291ed..31469144e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,10 @@
+<<<<<<< HEAD
+=======
## 1.11.0 (2015-12-12)
(this space intentionally left blank)
+>>>>>>> v1.11.0
## 1.11.0.pre.2 (2015-12-06)
Bugfixes:
diff --git a/Rakefile b/Rakefile
index 445daf19b7..b4a52bf1a9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -59,7 +59,7 @@ namespace :spec do
# Strip secure_path so that RVM paths transmit through sudo -E
system "sudo sed -i '/secure_path/d' /etc/sudoers"
# Install groff so ronn can generate man/help pages
- sh "sudo apt-get install groff -y"
+ sh "sudo apt-get install groff-base -y"
# Install graphviz so that the viz specs can run
sh "sudo apt-get install graphviz -y 2>&1 | tail -n 2"
if RUBY_VERSION < "1.9"
diff --git a/lib/bundler.rb b/lib/bundler.rb
index be90b0628e..0002fafd6e 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -16,39 +16,40 @@ module Bundler
ORIGINAL_ENV = ENV.to_hash
SUDO_MUTEX = Mutex.new
- autoload :Definition, "bundler/definition"
- autoload :Dependency, "bundler/dependency"
- autoload :DepProxy, "bundler/dep_proxy"
- autoload :Deprecate, "bundler/deprecate"
- autoload :Dsl, "bundler/dsl"
- autoload :EndpointSpecification, "bundler/endpoint_specification"
- autoload :Environment, "bundler/environment"
- autoload :Env, "bundler/env"
- autoload :Fetcher, "bundler/fetcher"
- autoload :GemHelper, "bundler/gem_helper"
- autoload :GemHelpers, "bundler/gem_helpers"
- autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
- autoload :Graph, "bundler/graph"
- autoload :Index, "bundler/index"
- autoload :Installer, "bundler/installer"
- autoload :Injector, "bundler/injector"
- autoload :LazySpecification, "bundler/lazy_specification"
- autoload :LockfileParser, "bundler/lockfile_parser"
- autoload :MatchPlatform, "bundler/match_platform"
- autoload :RemoteSpecification, "bundler/remote_specification"
- autoload :Resolver, "bundler/resolver"
- autoload :Retry, "bundler/retry"
- autoload :RubyVersion, "bundler/ruby_version"
- autoload :RubyDsl, "bundler/ruby_dsl"
- autoload :Runtime, "bundler/runtime"
- autoload :Settings, "bundler/settings"
- autoload :SharedHelpers, "bundler/shared_helpers"
- autoload :SpecSet, "bundler/spec_set"
- autoload :StubSpecification, "bundler/stub_specification"
- autoload :Source, "bundler/source"
- autoload :SourceList, "bundler/source_list"
- autoload :SystemRubyVersion, "bundler/ruby_version"
- autoload :UI, "bundler/ui"
+ autoload :Definition, "bundler/definition"
+ autoload :Dependency, "bundler/dependency"
+ autoload :DepProxy, "bundler/dep_proxy"
+ autoload :Deprecate, "bundler/deprecate"
+ autoload :Dsl, "bundler/dsl"
+ autoload :EndpointSpecification, "bundler/endpoint_specification"
+ autoload :Environment, "bundler/environment"
+ autoload :Env, "bundler/env"
+ autoload :Fetcher, "bundler/fetcher"
+ autoload :GemHelper, "bundler/gem_helper"
+ autoload :GemHelpers, "bundler/gem_helpers"
+ autoload :Graph, "bundler/graph"
+ autoload :Index, "bundler/index"
+ autoload :Installer, "bundler/installer"
+ autoload :Injector, "bundler/injector"
+ autoload :LazySpecification, "bundler/lazy_specification"
+ autoload :LockfileParser, "bundler/lockfile_parser"
+ autoload :MatchPlatform, "bundler/match_platform"
+ autoload :RemoteSpecification, "bundler/remote_specification"
+ autoload :Resolver, "bundler/resolver"
+ autoload :Retry, "bundler/retry"
+ autoload :RubyVersion, "bundler/ruby_version"
+ autoload :RubyDsl, "bundler/ruby_dsl"
+ autoload :Runtime, "bundler/runtime"
+ autoload :Settings, "bundler/settings"
+ autoload :SharedHelpers, "bundler/shared_helpers"
+ autoload :SpecSet, "bundler/spec_set"
+ autoload :StubSpecification, "bundler/stub_specification"
+ autoload :Source, "bundler/source"
+ autoload :SourceList, "bundler/source_list"
+ autoload :SystemRubyVersion, "bundler/ruby_version"
+ autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
+ autoload :RubyVersionRequirement, "bundler/ruby_version"
+ autoload :UI, "bundler/ui"
class << self
attr_writer :bundle_path
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 5f06fea6e7..67f6c28884 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -192,6 +192,8 @@ module Bundler
"Update a specific source (and all gems associated with it)"
method_option "force", :type => :boolean, :banner =>
"Force downloading every gem."
+ method_option "ruby", :type => :boolean, :banner =>
+ "Update ruby specified in Gemfile.lock"
def update(*gems)
require "bundler/cli/update"
Update.new(options, gems).run
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 81642d543e..62abc13b58 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -12,7 +12,7 @@ module Bundler
sources = Array(options[:source])
groups = Array(options[:group]).map(&:to_sym)
- if gems.empty? && sources.empty? && groups.empty?
+ if gems.empty? && sources.empty? && groups.empty? && !options[:ruby]
# We're doing a full update
Bundler.definition(true)
else
@@ -33,7 +33,7 @@ module Bundler
gems.concat(specs.map(&:name))
end
- Bundler.definition(:gems => gems, :sources => sources)
+ Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby])
end
Bundler::Fetcher.disable_endpoint = options["full-index"]
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 7acd78ea0b..ed755ba2ac 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -40,7 +40,7 @@ module Bundler
# @param sources [Bundler::SourceList]
# @param unlock [Hash, Boolean, nil] Gems that have been requested
# to be updated or true if all gems should be updated
- # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
+ # @param ruby_version [Bundler::RubyVersionRequirement, nil] Requested Ruby Version
# @param optional_groups [Array(String)] A list of optional groups
def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [])
@unlocking = unlock == true || !unlock.empty?
@@ -61,6 +61,7 @@ module Bundler
locked = LockfileParser.new(@lockfile_contents)
@platforms = locked.platforms
@locked_bundler_version = locked.bundler_version
+ @locked_ruby_version = locked.ruby_version
if unlock != true
@locked_deps = locked.dependencies
@@ -194,8 +195,7 @@ module Bundler
last_resolve
else
# Run a resolve against the locally available gems
- requested_ruby_version = ruby_version.version if ruby_version
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, requested_ruby_version)
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version)
end
end
end
@@ -269,9 +269,7 @@ module Bundler
end
end
- # Returns the version of Bundler that is creating or has created
- # Gemfile.lock. Used in #to_lock.
- def lock_version
+ def locked_bundler_version
if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
new_version = Bundler::VERSION
end
@@ -279,6 +277,26 @@ module Bundler
new_version || @locked_bundler_version || Bundler::VERSION
end
+ def locked_ruby_version
+ if @unlock[:ruby]
+ if ruby_version && !@locked_ruby_version
+ return Bundler.ruby_version
+ elsif ruby_version && @locked_ruby_version
+ return Bundler.ruby_version
+ elsif !ruby_version && @locked_ruby_version
+ return nil
+ end
+ else
+ if ruby_version && !@locked_ruby_version
+ return Bundler.ruby_version
+ elsif ruby_version && @locked_ruby_version
+ return @locked_ruby_version
+ elsif !ruby_version && @locked_ruby_version
+ return @locked_ruby_version
+ end
+ end
+ end
+
def to_lock
out = ""
@@ -315,9 +333,14 @@ module Bundler
handled << dep.name
end
+ if locked_ruby_version
+ out << "\nRUBY VERSION\n"
+ out << " #{locked_ruby_version}\n"
+ end
+
# Record the version of Bundler that was used to create the lockfile
out << "\nBUNDLED WITH\n"
- out << " #{lock_version}\n"
+ out << " #{locked_bundler_version}\n"
out
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 497fbcb133..1412cb879b 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -12,11 +12,12 @@ require "strscan"
module Bundler
class LockfileParser
- attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version
+ attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
BUNDLED = "BUNDLED WITH"
DEPENDENCIES = "DEPENDENCIES"
PLATFORMS = "PLATFORMS"
+ RUBY = "RUBY VERSION"
GIT = "GIT"
GEM = "GEM"
PATH = "PATH"
@@ -46,6 +47,8 @@ module Bundler
@state = :dependency
elsif line == PLATFORMS
@state = :platform
+ elsif line == RUBY
+ @state = :ruby
elsif line == BUNDLED
@state = :bundled_with
elsif line =~ /^[^\s]/
@@ -193,5 +196,9 @@ module Bundler
@bundler_version = Gem::Version.create(line)
end
end
+
+ def parse_ruby(line)
+ @ruby_version = line.strip
+ end
end
end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index edced0077f..529a958c9d 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -130,7 +130,7 @@ module Bundler
def for?(platform, required_ruby_version)
if spec = @specs[platform]
if required_ruby_version && spec_required_ruby_version = spec.required_ruby_version
- spec_required_ruby_version.satisfied_by?(required_ruby_version)
+ spec_required_ruby_version.satisfied_by?(required_ruby_version.gem_version)
else
true
end
@@ -192,7 +192,7 @@ module Bundler
@search_for = {}
@base_dg = Molinillo::DependencyGraph.new
@base.each {|ls| @base_dg.add_vertex(ls.name, Dependency.new(ls.name, ls.version), true) }
- @ruby_version = ruby_version ? Gem::Version.create(ruby_version) : nil
+ @ruby_version = ruby_version
end
def start(requirements)
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
index 46587e98cf..745fb19185 100644
--- a/lib/bundler/ruby_dsl.rb
+++ b/lib/bundler/ruby_dsl.rb
@@ -5,7 +5,7 @@ module Bundler
raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
raise GemfileEvalError, "ruby_version must match the :engine_version for MRI" if options[:engine] == "ruby" && options[:engine_version] && ruby_version != options[:engine_version]
- @ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
+ @ruby_version = RubyVersionRequirement.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
end
end
end
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index 34268c79f2..a456ebca46 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -38,24 +38,6 @@ module Bundler
patchlevel == other.patchlevel
end
- # Returns a tuple of these things:
- # [diff, this, other]
- # The priority of attributes are
- # 1. engine
- # 2. ruby_version
- # 3. engine_version
- def diff(other)
- if engine != other.engine && @input_engine
- [:engine, engine, other.engine]
- elsif version != other.version
- [:version, version, other.version]
- elsif engine_version != other.engine_version && @input_engine
- [:engine_version, engine_version, other.engine_version]
- elsif patchlevel != other.patchlevel && @patchlevel
- [:patchlevel, patchlevel, other.patchlevel]
- end
- end
-
def host
@host ||= [
RbConfig::CONFIG["host_cpu"],
@@ -63,6 +45,10 @@ module Bundler
RbConfig::CONFIG["host_os"]
].join("-")
end
+
+ def gem_version
+ Gem::Version.new(version)
+ end
end
# A subclass of RubyVersion that implements version,
@@ -111,4 +97,69 @@ module Bundler
RUBY_PATCHLEVEL.to_s
end
end
+
+ class RubyVersionRequirement
+ def initialize(version, patchlevel, engine, engine_version)
+ @ruby_version = RubyVersion.new version, patchlevel, engine, engine_version
+ end
+
+ # Returns a tuple of these things:
+ # [diff, this, other]
+ # The priority of attributes are
+ # 1. engine
+ # 2. ruby_version
+ # 3. engine_version
+ def diff(other)
+ if engine != other.engine && input_engine
+ [:engine, engine, other.engine]
+ elsif !version || !matches?(version, other.version)
+ [:version, version, other.version]
+ elsif input_engine && !matches?(engine_version, other.engine_version)
+ [:engine_version, engine_version, other.engine_version]
+ elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
+ [:patchlevel, patchlevel, other.patchlevel]
+ end
+ end
+
+ def gem_version
+ @ruby_version.gem_version
+ end
+
+ def ==(other)
+ version == other.version &&
+ engine == other.engine &&
+ engine_version == other.engine_version &&
+ patchlevel == other.patchlevel
+ end
+
+ def input_engine
+ @ruby_version.instance_variable_get(:@input_engine)
+ end
+
+ def engine
+ @ruby_version.engine
+ end
+
+ def patchlevel
+ @ruby_version.patchlevel
+ end
+
+ def engine_version
+ @ruby_version.engine_version
+ end
+
+ def version
+ @ruby_version.version
+ end
+
+ def to_s
+ @ruby_version.to_s
+ end
+
+ private
+
+ def matches?(requirement, version)
+ Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.new(version))
+ end
+ end
end
diff --git a/lib/bundler/templates/newgem/.travis.yml.tt b/lib/bundler/templates/newgem/.travis.yml.tt
index d78885d0ee..fe0761cc23 100644
--- a/lib/bundler/templates/newgem/.travis.yml.tt
+++ b/lib/bundler/templates/newgem/.travis.yml.tt
@@ -1,3 +1,4 @@
+sudo: false
language: ruby
rvm:
- <%= RUBY_VERSION %>
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/commands/install_spec.rb b/spec/commands/install_spec.rb
index 5132e4cffb..7ca40092f1 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
+
+ DEPENDENCIES
+
+ RUBY VERSION
+ ruby 2.1.3p100
+
+ 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
+
+ DEPENDENCIES
+
+ RUBY VERSION
+ ruby 2.1.3p100
+
+ 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..6bdca75ffe 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
+
+ DEPENDENCIES
+
+ RUBY VERSION
+ ruby 2.1.4p222
+
+ 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
+
+ DEPENDENCIES
+
+ RUBY VERSION
+ ruby 1.8.3p55
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index 1f48bcb3e0..780298ebc7 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
+
+ DEPENDENCIES
+ rack (> 0.9, < 1.0)
+
+ RUBY VERSION
+ ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
+
+ 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 d4dc96419c..0bf11bff34 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