diff options
Diffstat (limited to 'spec/bundler/bundler/definition_spec.rb')
-rw-r--r-- | spec/bundler/bundler/definition_spec.rb | 101 |
1 files changed, 91 insertions, 10 deletions
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index 73d44a93ab..5abf0d9756 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "spec_helper" + require "bundler/definition" RSpec.describe Bundler::Definition do describe "#lock" do before do allow(Bundler).to receive(:settings) { Bundler::Settings.new(".") } - allow(Bundler).to receive(:default_gemfile) { Pathname.new("Gemfile") } + allow(Bundler::SharedHelpers).to receive(:find_gemfile) { Pathname.new("Gemfile") } allow(Bundler).to receive(:ui) { double("UI", :info => "", :debug => "") } end context "when it's not possible to write to the file" do @@ -32,7 +32,7 @@ RSpec.describe Bundler::Definition do end describe "detects changes" do - it "for a path gem with changes" do + it "for a path gem with changes", :bundler => "< 2" do build_lib "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G @@ -70,7 +70,45 @@ RSpec.describe Bundler::Definition do G end - it "for a path gem with deps and no changes" do + it "for a path gem with changes", :bundler => "2" do + build_lib "foo", "1.0", :path => lib_path("foo") + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "foo", :path => "#{lib_path("foo")}" + G + + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "1.0" + end + + bundle :install, :env => { "DEBUG" => 1 } + + expect(out).to match(/re-resolving dependencies/) + lockfile_should_be <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack (= 1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + end + + it "for a path gem with deps and no changes", :bundler => "< 2" do build_lib "foo", "1.0", :path => lib_path("foo") do |s| s.add_dependency "rack", "1.0" s.add_development_dependency "net-ssh", "1.0" @@ -107,6 +145,43 @@ RSpec.describe Bundler::Definition do G end + it "for a path gem with deps and no changes", :bundler => "2" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "1.0" + s.add_development_dependency "net-ssh", "1.0" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "foo", :path => "#{lib_path("foo")}" + G + + bundle :check, :env => { "DEBUG" => 1 } + + expect(out).to match(/using resolution from the lockfile/) + lockfile_should_be <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack (= 1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + end + it "for a rubygems gem" do install_gemfile <<-G source "file://#{gem_repo1}" @@ -123,7 +198,7 @@ RSpec.describe Bundler::Definition do foo (1.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES foo @@ -160,6 +235,12 @@ RSpec.describe Bundler::Definition do end context "eager unlock" do + let(:source_list) do + Bundler::SourceList.new.tap do |source_list| + source_list.global_rubygems_source = "file://#{gem_repo4}" + end + end + before do gemfile <<-G source "file://#{gem_repo4}" @@ -203,11 +284,11 @@ RSpec.describe Bundler::Definition do definition = Bundler::Definition.new( bundled_app("Gemfile.lock"), updated_deps_in_gemfile, - Bundler::SourceList.new, + source_list, unlock_hash_for_bundle_install ) locked = definition.send(:converge_locked_specs).map(&:name) - expect(locked.include?("shared_dep")).to be_truthy + expect(locked).to include "shared_dep" end it "should not eagerly unlock shared dependency with bundle update conservative updating behavior" do @@ -217,11 +298,11 @@ RSpec.describe Bundler::Definition do definition = Bundler::Definition.new( bundled_app("Gemfile.lock"), updated_deps_in_gemfile, - Bundler::SourceList.new, + source_list, :gems => ["shared_owner_a"], :lock_shared_dependencies => true ) locked = definition.send(:converge_locked_specs).map(&:name) - expect(locked).to eq %w(isolated_dep isolated_owner shared_dep shared_owner_b) + expect(locked).to eq %w[isolated_dep isolated_owner shared_dep shared_owner_b] expect(locked.include?("shared_dep")).to be_truthy end end @@ -242,7 +323,7 @@ RSpec.describe Bundler::Definition do describe "find_indexed_specs" do it "with no platform set in indexed specs" do index = Bundler::Index.new - %w(1.0.0 1.0.1 1.1.0).each {|v| index << build_stub_spec("foo", v) } + %w[1.0.0 1.0.1 1.1.0].each {|v| index << build_stub_spec("foo", v) } dfn = Bundler::Definition.new(nil, [], mock_source_list, true) dfn.instance_variable_set("@index", index) |