Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3800 from pducks32/wrong-order-parallel-installer
Browse files Browse the repository at this point in the history
switch reject to select
  • Loading branch information
indirect committed Jul 2, 2015
2 parents d8c5e53 + 8cc6a7d commit fafd671
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
7 changes: 3 additions & 4 deletions lib/bundler/installer/parallel_installer.rb
Expand Up @@ -35,10 +35,9 @@ def ignorable_dependency?(dep)

# 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
Expand Down
40 changes: 33 additions & 7 deletions spec/install/parallel/spec_installation_spec.rb
Expand Up @@ -2,16 +2,16 @@
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)
Expand All @@ -34,4 +34,30 @@ def a_spec.name
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

0 comments on commit fafd671

Please sign in to comment.