Commit bb81dffc authored by Samuel Giddins's avatar Samuel Giddins

Add specs for PodfileDependencyCache

parent 2849fbd8
......@@ -3,6 +3,7 @@ module Pod
class Analyzer
# Caches podfile & target definition dependencies, so they do not need to be re-computed
# from the internal hash on each access
#
class PodfileDependencyCache
# @return [Array<Pod::Dependency>]
# All the dependencies in the podfile
......@@ -17,7 +18,8 @@ module Pod
# Returns the dependencies for the given target definition
#
def target_definition_dependencies(target_definition)
@dependencies_by_target_definition[target_definition] || raise("dependencies for #{target_definition.inspect} do not exist in the cache")
@dependencies_by_target_definition[target_definition] ||
raise(ArgumentError, "dependencies for #{target_definition.inspect} do not exist in the cache")
end
# Returns a list of all of the target definitions in the Podfile
......
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
class Installer
class Analyzer
describe PodfileDependencyCache do
describe '.from_podfile' do
it 'returns a warmed cache' do
podfile = Podfile.new do
pod 'A'
target 'T1' do
pod 'B'
target 'T1T' do
inherit! :search_paths
pod 'C'
end
end
target 'T2' do
pod 'B'
target 'T2T' do
inherit! :none
pod 'D'
end
end
end
cache = PodfileDependencyCache.from_podfile(podfile)
cache.podfile_dependencies.should == podfile.dependencies
target_definitions = podfile.target_definition_list
cache.target_definition_list.should == target_definitions
podfile.target_definition_list.each do |td|
cache.target_definition_dependencies(td).should == td.dependencies
end
lambda { cache.target_definition_dependencies(nil) }.should.raise(ArgumentError)
end
end
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