Commit ca845b7f authored by Olivier Halligon's avatar Olivier Halligon

[Command::Cache] "cache clean" spec + rubocop

parent 5ad0b2dd
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Command::Cache::Clean do
extend SpecHelper::Command
extend SpecHelper::TemporaryCache
before do
SpecHelper::TemporaryCache.set_up_test_cache
config.cache_root = SpecHelper::TemporaryCache.tmp_cache_path
end
it 'requires --all if no name given' do
e = lambda { run_command('cache', 'clean') }.should.raise CLAide::Help
e.message.should.match(/specify a pod name or use the --all flag/)
end
it 'asks the pod to clean when multiple matches' do
e = lambda { run_command('cache', 'clean', 'AFNetworking') }.should.raise Pod::Informative
e.message.should == '[!] 0 is invalid [1-2]'
end
it 'clean all matching pod when given a name and --all' do
run_command('cache', 'clean', '--all', 'AFNetworking')
Dir.glob(tmp_cache_path + '**/AFNetworking').select { |f| File.file?(f) }.should == []
end
it 'clean all pods when given --all' do
run_command('cache', 'clean', '--all')
Dir.glob(tmp_cache_path + '**/*').should == []
end
it 'warns when no matching pod found in the cache' do
output = run_command('cache', 'clean', 'non-existing-pod')
output.should.match(/No cache for pod/)
end
end
end
...@@ -29,7 +29,7 @@ module Pod ...@@ -29,7 +29,7 @@ module Pod
it 'shows the long form without --short' do it 'shows the long form without --short' do
output = run_command('cache', 'list', 'AFNetworking') output = run_command('cache', 'list', 'AFNetworking')
yaml = YAML.load(output) yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key,_| yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key, _|
key == 'AFNetworking' key == 'AFNetworking'
end end
end end
...@@ -38,11 +38,10 @@ module Pod ...@@ -38,11 +38,10 @@ module Pod
run_command('cache', 'list', '--short', 'bananalib') run_command('cache', 'list', '--short', 'bananalib')
output = run_command('cache', 'list', 'AFNetworking') output = run_command('cache', 'list', 'AFNetworking')
yaml = YAML.load(output) yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key,_| yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key, _|
['AFNetworking', '$CACHE_ROOT'].include?(key) ['AFNetworking', '$CACHE_ROOT'].include?(key)
end end
end end
end end
end end
end end
...@@ -26,31 +26,30 @@ module SpecHelper ...@@ -26,31 +26,30 @@ module SpecHelper
cache_root = "#{tmp_cache_path}/Pods" cache_root = "#{tmp_cache_path}/Pods"
root_path = short ? '' : "#{cache_root}/" root_path = short ? '' : "#{cache_root}/"
yaml = { yaml = {
"AFNetworking" => [ 'AFNetworking' => [
{ "Version"=>"2.5.4", { 'Version' => '2.5.4',
"Type" => "External", 'Type' => 'External',
"Spec" => "#{root_path}Specs/External/AFNetworking/d9ac25e7b83cea885663771c90998c47.podspec.json", 'Spec' => "#{root_path}Specs/External/AFNetworking/d9ac25e7b83cea885663771c90998c47.podspec.json",
"Pod" => "#{root_path}External/AFNetworking/e84d20f40f2049470632ce56ff0ce26f-05edc" 'Pod' => "#{root_path}External/AFNetworking/e84d20f40f2049470632ce56ff0ce26f-05edc",
},
{ 'Version' => '2.5.4',
'Type' => 'Release',
'Spec' => "#{root_path}Specs/Release/AFNetworking/2.5.podspec.json",
'Pod' => "#{root_path}Release/AFNetworking/2.5.4-05edc",
},
],
'CocoaLumberjack' => [
{ 'Version' => '2.0.0',
'Type' => 'Release',
'Spec' => "#{root_path}Specs/Release/CocoaLumberjack/2.0.podspec.json",
'Pod' => "#{root_path}Release/CocoaLumberjack/2.0.0-a6f77",
}, },
{ "Version" => "2.5.4",
"Type" => "Release",
"Spec"=>"#{root_path}Specs/Release/AFNetworking/2.5.podspec.json",
"Pod"=>"#{root_path}Release/AFNetworking/2.5.4-05edc"
}
], ],
"CocoaLumberjack" => [
{ "Version" => "2.0.0",
"Type" => "Release",
"Spec" => "#{root_path}Specs/Release/CocoaLumberjack/2.0.podspec.json",
"Pod" => "#{root_path}Release/CocoaLumberjack/2.0.0-a6f77"
}
]
} }
yaml['$CACHE_ROOT'] = cache_root if short yaml['$CACHE_ROOT'] = cache_root if short
yaml yaml
end end
module_function :set_up_test_cache, :tmp_cache_path, :test_cache_yaml module_function :set_up_test_cache, :tmp_cache_path, :test_cache_yaml
end end
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