diff options
author | Asutosh Palai <asupalai@gmail.com> | 2016-06-09 17:36:32 +0530 |
---|---|---|
committer | Asutosh Palai <asupalai@gmail.com> | 2016-06-09 17:36:35 +0530 |
commit | 7804310adb9e0b24798ed0cf33f29666a359ea4d (patch) | |
tree | aa5d814d9490088053001b9836d702965d2f196b | |
parent | 9d81750db1a32e900c3a27069f3a1427272b6a1f (diff) | |
download | bundler-7804310adb9e0b24798ed0cf33f29666a359ea4d.tar.gz |
Defaulting to Gem.sources for cli install
-rw-r--r-- | lib/bundler/plugin/installer.rb | 15 | ||||
-rw-r--r-- | spec/bundler/plugin/installer_spec.rb | 10 | ||||
-rw-r--r-- | spec/plugins/install.rb | 8 |
3 files changed, 14 insertions, 19 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 5b8bc3af08..7380977cf4 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -16,11 +16,9 @@ module Bundler if options[:git] install_git(names, version, options) - elsif options[:source] - source = options[:source] - install_rubygems(names, version, source) else - raise(ArgumentError, "You need to provide the source") + sources = options[:source] || Gem.sources.sources.map(&:uri) + install_rubygems(names, version, sources) end end @@ -49,7 +47,7 @@ module Bundler source_list = SourceList.new source_list.add_git_source(options) - # To support bot sources + # To support both sources if options[:source] source_list.add_rubygems_source("remotes" => options[:source]) end @@ -65,13 +63,14 @@ module Bundler # # @param [String] name of the plugin gem to search in the source # @param [Array] version of the gem to install - # @param [String] source the rubygems URL to resolve the gem + # @param [String, Array<String>] source(s) to resolve the gem # # @return [String] the path where the plugin was installed - def install_rubygems(names, version, source) + def install_rubygems(names, version, sources) deps = names.map {|name| Dependency.new name, version } + source_list = SourceList.new - source_list.add_rubygems_source("remotes" => source) + source_list.add_rubygems_source("remotes" => sources) definition = Definition.new(nil, deps, source_list, {}) install_definition(definition) diff --git a/spec/bundler/plugin/installer_spec.rb b/spec/bundler/plugin/installer_spec.rb index 936732f01a..f74d025403 100644 --- a/spec/bundler/plugin/installer_spec.rb +++ b/spec/bundler/plugin/installer_spec.rb @@ -5,9 +5,13 @@ describe Bundler::Plugin::Installer do subject(:installer) { Bundler::Plugin::Installer.new } describe "cli install" do - it "raises error when non of the source is provided" do - expect { installer.install("new-plugin", {}) }. - to raise_error(ArgumentError) + it "uses Gem.sources when non of the source is provided" do + sources = Gem.sources.sources.map(&:uri) + + allow(installer).to receive(:install_rubygems). + with("new-plugin", [">= 0"], sources).once + + installer.install("new-plugin", {}) end describe "with mocked installers" do diff --git a/spec/plugins/install.rb b/spec/plugins/install.rb index 08f055e7ac..03868832d2 100644 --- a/spec/plugins/install.rb +++ b/spec/plugins/install.rb @@ -9,14 +9,6 @@ describe "bundler plugin install" do end end - it "fails when source in not provided" do - bundle "plugin install foo" - - expect(out).to include("You need to provide the source") - - expect(out).not_to include("Installed plugin") - end - it "shows propper message when gem in not found in the source" do bundle "plugin install no-foo --source file://#{gem_repo1}" |