diff options
Diffstat (limited to 'spec/install/gemfile/platform_spec.rb')
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 58129bb313..c6eaec7ca6 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "spec_helper" -describe "bundle install across platforms" do +RSpec.describe "bundle install across platforms" do it "maintains the same lockfile if all gems are compatible across platforms" do lockfile <<-G GEM @@ -88,6 +88,32 @@ describe "bundle install across platforms" do expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3" end + it "works with gems that have extra platform-specific runtime dependencies" do + simulate_platform x64_mac + + update_repo2 do + build_gem "facter", "2.4.6" + build_gem "facter", "2.4.6" do |s| + s.platform = "universal-darwin" + s.add_runtime_dependency "CFPropertyList" + end + build_gem "CFPropertyList" + end + + install_gemfile! <<-G + source "file://#{gem_repo2}" + + gem "facter" + G + + expect(out).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \ + "because it has different dependencies from the ruby version. " \ + "To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again." + + expect(the_bundle).to include_gem "facter 2.4.6" + expect(the_bundle).not_to include_gem "CFPropertyList" + end + it "fetches gems again after changing the version of Ruby" do gemfile <<-G source "file://#{gem_repo1}" @@ -105,7 +131,7 @@ describe "bundle install across platforms" do end end -describe "bundle install with platform conditionals" do +RSpec.describe "bundle install with platform conditionals" do it "installs gems tagged w/ the current platforms" do install_gemfile <<-G source "file://#{gem_repo1}" @@ -184,7 +210,7 @@ describe "bundle install with platform conditionals" do gemfile <<-G source "file://#{gem_repo1}" - gem "some_gem", platform: :rbx + gem "some_gem", :platform => :rbx G bundle "install --local" @@ -204,9 +230,26 @@ describe "bundle install with platform conditionals" do bundle "install --local" expect(out).not_to match(/Could not find gem 'some_gem/) end + + it "prints a helpful warning when a dependency is unused on any platform" do + simulate_platform "ruby" + simulate_ruby_engine "ruby" + + gemfile <<-G + source "file://#{gem_repo1}" + + gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] + G + + bundle! "install" + + expect(out).to include <<-O.strip +The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. + O + end end -describe "when a gem has no architecture" do +RSpec.describe "when a gem has no architecture" do it "still installs correctly" do simulate_platform mswin @@ -216,7 +259,7 @@ describe "when a gem has no architecture" do gem "rcov" G - bundle :install, :fakeweb => "windows" + bundle :install, :artifice => "windows" expect(the_bundle).to include_gems "rcov 1.0.0" end end |