diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-01-31 21:13:41 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-02-01 15:45:25 -0600 |
commit | 897aaf734888a578ba559aaadde8448da38d1b19 (patch) | |
tree | aa6a88a97b0e9b6bf74ddc212f5bcc5b899ae512 | |
parent | db227665aab59316183c508b85571022ef59eb7a (diff) | |
download | bundler-897aaf734888a578ba559aaadde8448da38d1b19.tar.gz |
Add specs for bundle platform --ruby with version requirements
-rw-r--r-- | lib/bundler/cli/platform.rb | 4 | ||||
-rw-r--r-- | lib/bundler/ruby_version.rb | 6 | ||||
-rw-r--r-- | spec/other/platform_spec.rb | 35 |
3 files changed, 42 insertions, 3 deletions
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb index 4edfd342e4..b5f906bfd9 100644 --- a/lib/bundler/cli/platform.rb +++ b/lib/bundler/cli/platform.rb @@ -8,8 +8,10 @@ module Bundler def run platforms, ruby_version = Bundler.ui.silence do + locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version + gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string [Bundler.definition.platforms.map {|p| "* #{p}" }, - (Bundler.locked_gems && Bundler.locked_gems.ruby_version) || Bundler.definition.ruby_version] + locked_ruby_version || gemfile_ruby_version] end output = [] diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb index 27ae42bfa1..77ab442e19 100644 --- a/lib/bundler/ruby_version.rb +++ b/lib/bundler/ruby_version.rb @@ -24,7 +24,7 @@ module Bundler @patchlevel = patchlevel end - def to_s + def to_s(version = self.version) output = String.new("ruby #{version}") output << "p#{patchlevel}" if patchlevel output << " (#{engine} #{engine_version})" unless engine == "ruby" @@ -32,6 +32,10 @@ module Bundler output end + def single_version_string + to_s(gem_version) + end + def ==(other) version == other.version && engine == other.engine && diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index 7942e604a5..be71582b54 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -191,10 +191,43 @@ G G bundle "platform --ruby" - puts err expect(out).to eq("No ruby version specified") end + + it "handles when there is a locked requirement" do + gemfile <<-G + ruby "< 1.8.7" + G + + lockfile <<-L + GEM + specs: + + PLATFORMS + ruby + + DEPENDENCIES + + RUBY VERSION + ruby 1.0.0p127 + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle! "platform --ruby" + expect(out).to eq("ruby 1.0.0p127") + end + + it "handles when there is a requirement in the gemfile" do + gemfile <<-G + ruby ">= 1.8.7" + G + + bundle! "platform --ruby" + expect(out).to eq("ruby 1.8.7") + end end let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" } |