homebrew-cask-versions/test/cask/cli_test.rb
Keith Smiley 6404f82d09 Verify appdir after reading command line opts
Helps prevent default appdir from being created regardless of whether
the user configured it or not.

Closes #496
2013-06-15 20:13:05 -05:00

47 lines
1.3 KiB
Ruby

require 'test_helper'
describe Cask::CLI do
it "lists the taps for casks that show up in two taps" do
Cask::CLI.nice_listing(%w[
phinze-cask/adium
phinze-cask/google-chrome
passcod-cask/adium
]).must_equal(%w[
google-chrome
passcod-cask/adium
phinze-cask/adium
])
end
describe "process" do
it "creates the appdir if it does not exist" do
Cask.appdir.rmdir
shutup {
Cask::CLI.process('list')
}
Cask.appdir.directory?.must_equal true
end
it "respects the env variable when choosing what appdir to create, not touching the default appdir" do
default_applications_dir = Cask.appdir
default_applications_dir.rmdir
custom_applications_dir = Pathname(Dir.mktmpdir('custom_app_dir'))
custom_applications_dir.rmdir
default_applications_dir.directory?.must_equal false
custom_applications_dir.directory?.must_equal false
begin
ENV['HOMEBREW_CASK_OPTS'] = "--appdir=#{custom_applications_dir}"
shutup {
Cask::CLI.process('list')
}
ensure
ENV.delete 'HOMEBREW_CASK_OPTS'
end
default_applications_dir.directory?.must_equal false
custom_applications_dir.directory?.must_equal true
end
end
end