summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-06-28 00:38:52 +0900
committerHomu <homu@barosl.com>2016-06-28 00:38:52 +0900
commitbd8982c525bd79302d4551e1ad0053722de4b0b6 (patch)
tree4a72b4ef3918eb189bb21f1a7e51b744f2bf477c
parente5e79045eefd6502734091f4af79fa02f13f7b94 (diff)
parentbc544dfc89edf9bd6403342c79d0ac2490373f6e (diff)
downloadbundler-bd8982c525bd79302d4551e1ad0053722de4b0b6.tar.gz
Auto merge of #4321 - bundler:seg-gemspec-ruby, r=indirect
[DSL] Set ruby version when using the gemspec method - [x] Specs \c @indirect
-rw-r--r--lib/bundler/dsl.rb4
-rw-r--r--spec/install/gemfile/gemspec_spec.rb25
-rw-r--r--spec/support/helpers.rb1
3 files changed, 30 insertions, 0 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 07cddc1e84..aaa0eab06d 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -67,6 +67,10 @@ module Bundler
gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
gem spec.name, :path => path, :glob => glob, :platforms => gem_platforms
+ if !@ruby_version && spec.required_ruby_version && spec.required_ruby_version != Gem::Requirement.default
+ ruby(spec.required_ruby_version)
+ end
+
group(development_group) do
spec.development_dependencies.each do |dep|
gem dep.name, *(dep.requirement.as_list + [:type => :development])
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index a23b3f2cb6..62d13c0bd6 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -143,6 +143,31 @@ describe "bundle install from an existing gemspec" do
expect(@err).not_to match(/ahh/)
end
+ context "when the gemspec has a required_ruby_version" do
+ before do
+ build_lib "foo", :path => bundled_app do |s|
+ s.required_ruby_version = ">= 2.0"
+ end
+ end
+
+ it "uses the ruby version in the gemspec" do
+ install_gemfile! <<-G
+ gemspec
+ G
+ run! "puts Bundler.definition.ruby_version"
+ expect(out).to eq("ruby >= 2.0")
+ end
+
+ it "prefers the explicit ruby version" do
+ install_gemfile! <<-G
+ ruby "< 9999"
+ gemspec
+ G
+ run! "puts Bundler.definition.ruby_version"
+ expect(out).to eq("ruby < 9999")
+ end
+ end
+
context "when child gemspecs conflict with a released gemspec" do
before do
# build the "parent" gem that depends on another gem in the same repo
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index d2a812b3a1..a2bc04d942 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -204,6 +204,7 @@ module Spec
opts[:retry] ||= 0
bundle :install, opts
end
+ bang :install_gemfile
def lock_gemfile(*args)
gemfile(*args)