Permalink
Browse files

+ source spec

  • Loading branch information...
1 parent 2e893d1 commit de7fe36fb4a3ccb10903e9bf65f0df3b8c6c60aa @alloy alloy committed Sep 15, 2011
View
2 .gitignore
@@ -4,4 +4,4 @@
tmp
examples/Pods
spec/fixtures/banana-lib
-spec/fixtures/master-spec-repo.git
+spec/fixtures/spec-repos/master
View
2 lib/cocoa_pods/source.rb
@@ -5,7 +5,7 @@ def self.all
end
def self.search(dependency)
- all.map { |source| source.search(dependency) }.compact
+ all.map { |source| source.search(dependency) }.compact.first
end
attr_reader :repo
View
2 lib/cocoa_pods/specification/set.rb
@@ -17,6 +17,8 @@ def self.by_pod_dir(pod_dir)
sets[set.name]
end
+ attr_reader :pod_dir
+
def initialize(pod_dir)
@pod_dir = pod_dir
@required_by = []
View
BIN spec/fixtures/master-spec-repo.git.tar.gz
Binary file not shown.
View
43 spec/functional/command_spec.rb
@@ -2,52 +2,39 @@
describe "Pod::Command" do
extend SpecHelper::Git
- extend SpecHelper::Log
extend SpecHelper::TemporaryDirectory
before do
- fixture('master-spec-repo.git') # ensure the archive is unpacked
+ fixture('spec-repos/master') # ensure the archive is unpacked
end
it "creates the local spec-repos directory and creates a clone of the `master' repo" do
command = Pod::Command.parse('setup')
- def command.master_repo_url; SpecHelper.fixture('master-spec-repo.git'); end
+ def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
command.run
- git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s
- end
-
- def command(*argv)
- command = Pod::Command.parse(*argv)
- command.run
- command
+ git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end
it "adds a spec-repo" do
- command('repo', 'add', 'private', fixture('master-spec-repo.git'))
- git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s
+ add_repo('private', fixture('spec-repos/master'))
+ git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end
it "updates a spec-repo" do
- repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git'))
- repo2 = command('repo', 'add', 'repo2', repo1.dir)
-
- (repo1.dir + 'README').open('a') { |f| f << 'updated!' }
- git('repo1', 'commit -a -m "update"')
-
+ repo1 = add_repo('repo1', fixture('spec-repos/master'))
+ repo2 = add_repo('repo2', repo1.dir)
+ make_change(repo1, 'repo1')
command('repo', 'update', 'repo2')
- (repo2.dir + 'README').read.should.include 'updated!'
+ (repo2.dir + 'README').read.should.include 'Added!'
end
it "updates all the spec-repos" do
- repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git'))
- repo2 = command('repo', 'add', 'repo2', repo1.dir)
- repo3 = command('repo', 'add', 'repo3', repo1.dir)
-
- (repo1.dir + 'README').open('a') { |f| f << 'updated!' }
- git('repo1', 'commit -a -m "update"')
-
+ repo1 = add_repo('repo1', fixture('spec-repos/master'))
+ repo2 = add_repo('repo2', repo1.dir)
+ repo3 = add_repo('repo3', repo1.dir)
+ make_change(repo1, 'repo1')
command('repo', 'update')
- (repo2.dir + 'README').read.should.include 'updated!'
- (repo3.dir + 'README').read.should.include 'updated!'
+ (repo2.dir + 'README').read.should.include 'Added!'
+ (repo3.dir + 'README').read.should.include 'Added!'
end
end
View
22 spec/spec_helper/git.rb
@@ -21,11 +21,31 @@ def tmp_master_repo_path
alias_method :git_super, :git
def git(repo, command)
- Dir.chdir(tmp_repos_path + repo) { git_super(command).strip }
+ Dir.chdir(tmp_repos_path + repo) do
+ if output = git_super(command)
+ output.strip
+ end
+ end
end
def git_config(repo, attr)
git repo, "config --get #{attr}"
end
+
+ def command(*argv)
+ command = Pod::Command.parse(*argv)
+ command.run
+ command
+ end
+
+ def add_repo(name, from)
+ command('repo', 'add', name, from)
+ end
+
+ def make_change(repo, name)
+ (repo.dir + 'README').open('w') { |f| f << 'Added!' }
+ git(name, 'add README')
+ git(name, 'commit -m "changed"')
+ end
end
end
View
18 spec/unit/installer_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe "Pod::Installer" do
+ before do
+ config.repos_dir = fixture('spec-repos/master')
+ @spec = Pod::Spec.new do
+ dependency 'SSZipArchive'
+ end
+ end
+
+ after do
+ config.repos_dir = SpecHelper.tmp_repos_path
+ end
+
+ it "" do
+
+ end
+end
View
23 spec/unit/source_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe "Pod::Source" do
+ extend SpecHelper::Git
+ extend SpecHelper::TemporaryDirectory
+
+ before do
+ add_repo('repo1', fixture('spec-repos/master'))
+ (config.repos_dir + 'repo1/JSONKit').rmtree
+ add_repo('repo2', fixture('spec-repos/master'))
+ (config.repos_dir + 'repo2/Reachability').rmtree
+ end
+
+ it "returns a specification set by name from any spec repo" do
+ set = Pod::Source.search(Pod::Dependency.new('Reachability'))
+ set.should.be.instance_of Pod::Specification::Set
+ set.pod_dir.should == config.repos_dir + 'repo1/Reachability'
+
+ set = Pod::Source.search(Pod::Dependency.new('JSONKit'))
+ set.should.be.instance_of Pod::Specification::Set
+ set.pod_dir.should == config.repos_dir + 'repo2/JSONKit'
+ end
+end

0 comments on commit de7fe36

Please sign in to comment.