Commit 5ad0b2dd authored by Olivier Halligon's avatar Olivier Halligon

[Command::Cache] "cache list" spec

parent b1228e70
require File.expand_path('../../../../spec_helper', __FILE__)
require 'yaml'
module Pod
describe Command::Cache::List do
extend SpecHelper::Command
extend SpecHelper::TemporaryCache
before do
SpecHelper::TemporaryCache.set_up_test_cache
config.cache_root = SpecHelper::TemporaryCache.tmp_cache_path
end
describe 'lists the whole content of the cache as YAML' do
it 'shows the long form without --short' do
output = run_command('cache', 'list')
yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false)
end
it 'shows the short form with --short' do
output = run_command('cache', 'list', '--short')
yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(true)
end
end
describe 'lists only the cache content for the requested pod as YAML' do
it 'shows the long form without --short' do
output = run_command('cache', 'list', 'AFNetworking')
yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key,_|
key == 'AFNetworking'
end
end
it 'shows the short form with --short' do
run_command('cache', 'list', '--short', 'bananalib')
output = run_command('cache', 'list', 'AFNetworking')
yaml = YAML.load(output)
yaml.should == SpecHelper::TemporaryCache.test_cache_yaml(false).select do |key,_|
['AFNetworking', '$CACHE_ROOT'].include?(key)
end
end
end
end
end
......@@ -22,7 +22,35 @@ module SpecHelper
SpecHelper.temporary_directory + 'cocoapods/cache/CocoaPods'
end
module_function :set_up_test_cache, :tmp_cache_path
def test_cache_yaml(short = false)
cache_root = "#{tmp_cache_path}/Pods"
root_path = short ? '' : "#{cache_root}/"
yaml = {
"AFNetworking" => [
{ "Version"=>"2.5.4",
"Type" => "External",
"Spec" => "#{root_path}Specs/External/AFNetworking/d9ac25e7b83cea885663771c90998c47.podspec.json",
"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"
}
]
}
yaml['$CACHE_ROOT'] = cache_root if short
yaml
end
module_function :set_up_test_cache, :tmp_cache_path, :test_cache_yaml
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