Commit 74844565 authored by Eloy Duran's avatar Eloy Duran

+ resolver spec

parent b7284de3
...@@ -12,16 +12,11 @@ module Pod ...@@ -12,16 +12,11 @@ module Pod
def find_dependency_sets(specification) def find_dependency_sets(specification)
specification.read(:dependencies).each do |dependency| specification.read(:dependencies).each do |dependency|
sets = Source.search(dependency) set = Source.search(dependency)
if sets.empty? set.required_by(specification)
raise "Unable to find a pod named `#{dependency.name}'" unless @sets.include?(set)
end @sets << set
sets.each do |set| find_dependency_sets(set.specification)
set.required_by(specification, dependency)
unless @sets.include?(set)
@sets << set
find_dependency_sets(set.specification)
end
end end
end end
end end
......
...@@ -5,7 +5,8 @@ module Pod ...@@ -5,7 +5,8 @@ module Pod
end end
def self.search(dependency) 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 end
attr_reader :repo attr_reader :repo
......
...@@ -30,3 +30,15 @@ end ...@@ -30,3 +30,15 @@ end
config = Pod::Config.instance config = Pod::Config.instance
config.silent = true config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path 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__) ...@@ -2,17 +2,14 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do describe "Pod::Installer" do
before 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 @spec = Pod::Spec.new do
dependency 'SSZipArchive' dependency 'JSONKit'
end end
end end
after do after do
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "" do
end
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 ...@@ -5,6 +5,8 @@ describe "Pod::Source" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
before do before do
Pod::Source.reset!
Pod::Spec::Set.reset!
add_repo('repo1', fixture('spec-repos/master')) add_repo('repo1', fixture('spec-repos/master'))
(config.repos_dir + 'repo1/JSONKit').rmtree (config.repos_dir + 'repo1/JSONKit').rmtree
add_repo('repo2', fixture('spec-repos/master')) add_repo('repo2', fixture('spec-repos/master'))
...@@ -20,4 +22,10 @@ describe "Pod::Source" do ...@@ -20,4 +22,10 @@ describe "Pod::Source" do
set.should.be.instance_of Pod::Specification::Set set.should.be.instance_of Pod::Specification::Set
set.pod_dir.should == config.repos_dir + 'repo2/JSONKit' set.pod_dir.should == config.repos_dir + 'repo2/JSONKit'
end end
it "raises if a specification set can't be found" do
lambda {
Pod::Source.search(Pod::Dependency.new('DoesNotExist'))
}.should.raise
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