summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-07-01 22:12:06 -0700
committerAndré Arko <mail@arko.net>2015-07-01 22:12:06 -0700
commitfafd671635036cb74c4bb28e3c1d25ce63a9d400 (patch)
tree9b05d66eceb04473b2400836e0b1b832a39dc8f4
parentd8c5e53b6e3115498e67b06158b42d59905a417e (diff)
parent8cc6a7d5aaa5e3097eb7eac101df134f8d068a10 (diff)
downloadbundler-fafd671635036cb74c4bb28e3c1d25ce63a9d400.tar.gz
Merge pull request #3800 from pducks32/wrong-order-parallel-installer
switch reject to select
-rw-r--r--lib/bundler/installer/parallel_installer.rb7
-rw-r--r--spec/install/parallel/spec_installation_spec.rb40
2 files changed, 36 insertions, 11 deletions
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 9c08c83b4c..6e05f73cb9 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -35,10 +35,9 @@ class ParallelInstaller
# Checks installed dependencies against spec's dependencies to make
# sure needed dependencies have been installed.
- def dependencies_installed?(remaining_specs)
- installed_specs = remaining_specs.reject(&:installed?).map(&:name)
- already_installed = lambda {|dep| installed_specs.include? dep.name }
- dependencies.all? {|d| already_installed[d] }
+ def dependencies_installed?(all_specs)
+ installed_specs = all_specs.select(&:installed?).map(&:name)
+ dependencies.all? {|d| installed_specs.include? d.name }
end
# Represents only the non-development dependencies and the ones that
diff --git a/spec/install/parallel/spec_installation_spec.rb b/spec/install/parallel/spec_installation_spec.rb
index 97288fe02f..8cb6ea8a49 100644
--- a/spec/install/parallel/spec_installation_spec.rb
+++ b/spec/install/parallel/spec_installation_spec.rb
@@ -2,16 +2,16 @@ require 'spec_helper'
require 'bundler/installer/parallel_installer'
describe ParallelInstaller::SpecInstallation do
- describe "#ready_to_enqueue?" do
- let!(:dep) do
- a_spec = Object.new
- def a_spec.name
- "I like tests"
- end
- a_spec
+ let!(:dep) do
+ a_spec = Object.new
+ def a_spec.name
+ "I like tests"
end
+ a_spec
+ end
+ describe "#ready_to_enqueue?" do
context "when in enqueued state" do
it "is falsey" do
spec = ParallelInstaller::SpecInstallation.new(dep)
@@ -34,4 +34,30 @@ describe ParallelInstaller::SpecInstallation do
end
end
+ describe "#dependencies_installed?" do
+ context "when all dependencies are installed" do
+ it "returns true" do
+ dependencies = []
+ dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => true, :all_dependencies => [], :type => :production)
+ dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => true, :all_dependencies => [], :type => :production)
+ all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)]
+ spec = ParallelInstaller::SpecInstallation.new(dep)
+ allow(spec).to receive(:all_dependencies).and_return(dependencies)
+ expect(spec.dependencies_installed?(all_specs)).to be_truthy
+ end
+ end
+
+ context "when all dependencies are not installed" do
+ it "returns false" do
+ dependencies = []
+ dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => false, :all_dependencies => [], :type => :production)
+ dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => true, :all_dependencies => [], :type => :production)
+ all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)]
+ spec = ParallelInstaller::SpecInstallation.new(dep)
+ allow(spec).to receive(:all_dependencies).and_return(dependencies)
+ expect(spec.dependencies_installed?(all_specs)).to be_falsey
+ end
+ end
+ end
+
end