Commit 74844565 authored by Eloy Duran's avatar Eloy Duran

+ resolver spec

parent b7284de3
......@@ -12,12 +12,8 @@ module Pod
def find_dependency_sets(specification)
specification.read(:dependencies).each do |dependency|
sets = Source.search(dependency)
if sets.empty?
raise "Unable to find a pod named `#{dependency.name}'"
end
sets.each do |set|
set.required_by(specification, dependency)
set = Source.search(dependency)
set.required_by(specification)
unless @sets.include?(set)
@sets << set
find_dependency_sets(set.specification)
......@@ -25,5 +21,4 @@ module Pod
end
end
end
end
end
......@@ -5,7 +5,8 @@ module Pod
end
def self.search(dependency)
all.map { |source| source.search(dependency) }.compact.first
all.map { |source| source.search(dependency) }.compact.first ||
raise("Unable to find a pod named `#{dependency.name}'")
end
attr_reader :repo
......
......@@ -30,3 +30,15 @@ end
config = Pod::Config.instance
config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path
class Pod::Source
def self.reset!
@sources = nil
end
end
class Pod::Spec::Set
def self.reset!
@sets = nil
end
end
......@@ -2,17 +2,14 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do
before do
config.repos_dir = fixture('spec-repos/master')
fixture('spec-repos/master') # ensure the archive is unpacked
config.repos_dir = fixture('spec-repos')
@spec = Pod::Spec.new do
dependency 'SSZipArchive'
dependency 'JSONKit'
end
end
after do
config.repos_dir = SpecHelper.tmp_repos_path
end
it "" do
end
end
require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Resolver" do
before do
fixture('spec-repos/master') # ensure the archive is unpacked
config.repos_dir = fixture('spec-repos')
end
after do
config.repos_dir = SpecHelper.tmp_repos_path
end
it "returns all sets needed for the dependency" do
sets = []
sets << Pod::Spec::Set.by_pod_dir(fixture('spec-repos/master/Reachability'))
sets << Pod::Spec::Set.by_pod_dir(fixture('spec-repos/master/ASIHTTPRequest'))
sets << Pod::Spec::Set.by_pod_dir(fixture('spec-repos/master/ASIWebPageRequest'))
resolver = Pod::Resolver.new(Pod::Spec.new { dependency 'ASIWebPageRequest' })
resolver.resolve.sort_by(&:name).should == sets.sort_by(&:name)
end
end
......@@ -5,6 +5,8 @@ describe "Pod::Source" do
extend SpecHelper::TemporaryDirectory
before do
Pod::Source.reset!
Pod::Spec::Set.reset!
add_repo('repo1', fixture('spec-repos/master'))
(config.repos_dir + 'repo1/JSONKit').rmtree
add_repo('repo2', fixture('spec-repos/master'))
......@@ -20,4 +22,10 @@ describe "Pod::Source" do
set.should.be.instance_of Pod::Specification::Set
set.pod_dir.should == config.repos_dir + 'repo2/JSONKit'
end
it "raises if a specification set can't be found" do
lambda {
Pod::Source.search(Pod::Dependency.new('DoesNotExist'))
}.should.raise
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