[Spec::Lint] Fail gracefully when downloading podspec fails

parent 42de87c8
...@@ -98,9 +98,13 @@ module Pod ...@@ -98,9 +98,13 @@ module Pod
require 'cocoapods/open-uri' require 'cocoapods/open-uri'
output_path = podspecs_tmp_dir + File.basename(path) output_path = podspecs_tmp_dir + File.basename(path)
output_path.dirname.mkpath output_path.dirname.mkpath
begin
open(path) do |io| open(path) do |io|
output_path.open('w') { |f| f << io.read } output_path.open('w') { |f| f << io.read }
end end
rescue => e
raise Informative, "Downloading a podspec from `#{path}` failed: #{e}"
end
files << output_path files << output_path
elsif (pathname = Pathname.new(path)).directory? elsif (pathname = Pathname.new(path)).directory?
files += Pathname.glob(pathname + '*.podspec{.json,}') files += Pathname.glob(pathname + '*.podspec{.json,}')
......
...@@ -193,7 +193,7 @@ module Pod ...@@ -193,7 +193,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe 'lint subcommand' do describe Command::Spec::Lint do
it "complains if it can't find any spec to lint" do it "complains if it can't find any spec to lint" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
lambda { command('spec', 'lint').run }.should.raise Informative lambda { command('spec', 'lint').run }.should.raise Informative
...@@ -214,6 +214,10 @@ module Pod ...@@ -214,6 +214,10 @@ module Pod
end end
end end
it 'fails with an informative error when downloading the podspec 404s' do
lambda { run_command('spec', 'lint', 'https://no.such.domain/404') }.should.raise Informative
end
before do before do
text = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read text = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read
text.gsub!(/.*license.*/, '"license": { "file": "LICENSE" },') text.gsub!(/.*license.*/, '"license": { "file": "LICENSE" },')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment