naked pkg - save files with spaces properly

This commit is contained in:
Paul Hinze 2013-09-22 08:15:28 -05:00
parent 6a9dae2570
commit 21f1cc6544
3 changed files with 24 additions and 2 deletions

View File

@ -3,5 +3,5 @@ class WavTap < Cask
homepage 'https://github.com/pje/wavtap'
version '0.2.0'
sha1 '9d71dcf769dd546d66278dc9cbf675df6b006fe6'
install 'wav-tap-0.2.0.pkg'
install 'WavTap 0.2.0.pkg'
end

View File

@ -10,7 +10,7 @@ class Cask::Container::Naked < Cask::Container::Base
end
def target_file
File.basename(@cask.url.path)
URI.decode(File.basename(@cask.url.path))
end
end

View File

@ -0,0 +1,22 @@
require 'test_helper'
describe Cask::Container::Naked do
it "saves files with spaces in them from uris with encoded spaces" do
SpaceyCask = Class.new(Cask)
SpaceyCask.class_eval do
url 'http://example.com/kevin%20spacey.pkg'
version '1.2'
end
cask = SpaceyCask.new
path = '/tmp/downloads/kevin-spacey-1.2.pkg'
expected_destination = cask.destination_path.join('kevin spacey.pkg')
expected_command = %Q(ditto '#{path}' '#{expected_destination}' 2>&1)
Cask::FakeSystemCommand.fake_response_for(expected_command)
container = Cask::Container::Naked.new(cask, path, Cask::FakeSystemCommand)
container.extract
Cask::FakeSystemCommand.system_calls[expected_command].must_equal 1
end
end