Commit 6e785527 authored by Francis Chong's avatar Francis Chong

refactor: raise a UnsupportedFileTypeError when unexpected file type is given

parent f1072e7e
......@@ -6,6 +6,8 @@ require 'yaml'
module Pod
class Downloader
class Http < Downloader
class UnsupportedFileTypeError < StandardError; end
executable :curl
executable :unzip
executable :tar
......@@ -49,7 +51,7 @@ module Pod
when :tar
"file.tar"
else
raise "Pod::Downloader::Http Unsupported file type: #{type}"
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end
end
......@@ -66,7 +68,7 @@ module Pod
when :tar
tar "xf '#{full_filename}' -d #{target_path}"
else
raise "Http Downloader: Unsupported file type"
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end
end
......
......@@ -56,4 +56,20 @@ describe Pod::Downloader::Http do
downloader.expects(:extract_with_type).with(anything(), :tgz).at_least_once
downloader.download
end
it 'should raise error when unsupported filetype is pass' do
downloader = Pod::Downloader.for_pod(stub_pod_with_source(
:http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0.rar'
))
downloader.expects(:download).raises(Pod::Downloader::Http::UnsupportedFileTypeError)
downloader.download rescue nil
downloader = Pod::Downloader.for_pod(stub_pod_with_source(
:http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0',
:type => :rar
))
downloader.expects(:download).raises(Pod::Downloader::Http::UnsupportedFileTypeError)
downloader.download rescue nil
end
end
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