Permalink
Browse files

+ resolver spec

  • Loading branch information...
1 parent b7284de commit 748445655c4d728f2ade347e43317bb3dfef9a64 @alloy alloy committed Sep 15, 2011
View
@@ -12,16 +12,11 @@ def resolve
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)
- unless @sets.include?(set)
- @sets << set
- find_dependency_sets(set.specification)
- end
+ set = Source.search(dependency)
+ set.required_by(specification)
+ unless @sets.include?(set)
+ @sets << set
+ find_dependency_sets(set.specification)
end
end
end
View
@@ -5,7 +5,8 @@ def self.all
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
View
@@ -30,3 +30,15 @@ def argv(*argv)
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 @@
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
View
@@ -0,0 +1,22 @@
+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
+
View
@@ -5,6 +5,8 @@
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 @@
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

0 comments on commit 7484456

Please sign in to comment.