Commit de7fe36f authored by Eloy Duran's avatar Eloy Duran

+ source spec

parent 2e893d13
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
tmp tmp
examples/Pods examples/Pods
spec/fixtures/banana-lib spec/fixtures/banana-lib
spec/fixtures/master-spec-repo.git spec/fixtures/spec-repos/master
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
end end
def self.search(dependency) def self.search(dependency)
all.map { |source| source.search(dependency) }.compact all.map { |source| source.search(dependency) }.compact.first
end end
attr_reader :repo attr_reader :repo
......
...@@ -17,6 +17,8 @@ module Pod ...@@ -17,6 +17,8 @@ module Pod
sets[set.name] sets[set.name]
end end
attr_reader :pod_dir
def initialize(pod_dir) def initialize(pod_dir)
@pod_dir = pod_dir @pod_dir = pod_dir
@required_by = [] @required_by = []
......
...@@ -2,52 +2,39 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,52 +2,39 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Command" do describe "Pod::Command" do
extend SpecHelper::Git extend SpecHelper::Git
extend SpecHelper::Log
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
before do before do
fixture('master-spec-repo.git') # ensure the archive is unpacked fixture('spec-repos/master') # ensure the archive is unpacked
end end
it "creates the local spec-repos directory and creates a clone of the `master' repo" do it "creates the local spec-repos directory and creates a clone of the `master' repo" do
command = Pod::Command.parse('setup') 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 command.run
git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end
def command(*argv)
command = Pod::Command.parse(*argv)
command.run
command
end end
it "adds a spec-repo" do it "adds a spec-repo" do
command('repo', 'add', 'private', fixture('master-spec-repo.git')) add_repo('private', fixture('spec-repos/master'))
git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end end
it "updates a spec-repo" do it "updates a spec-repo" do
repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git')) repo1 = add_repo('repo1', fixture('spec-repos/master'))
repo2 = command('repo', 'add', 'repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
make_change(repo1, 'repo1')
(repo1.dir + 'README').open('a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"')
command('repo', 'update', 'repo2') command('repo', 'update', 'repo2')
(repo2.dir + 'README').read.should.include 'updated!' (repo2.dir + 'README').read.should.include 'Added!'
end end
it "updates all the spec-repos" do it "updates all the spec-repos" do
repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git')) repo1 = add_repo('repo1', fixture('spec-repos/master'))
repo2 = command('repo', 'add', 'repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
repo3 = command('repo', 'add', 'repo3', repo1.dir) repo3 = add_repo('repo3', repo1.dir)
make_change(repo1, 'repo1')
(repo1.dir + 'README').open('a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"')
command('repo', 'update') command('repo', 'update')
(repo2.dir + 'README').read.should.include 'updated!' (repo2.dir + 'README').read.should.include 'Added!'
(repo3.dir + 'README').read.should.include 'updated!' (repo3.dir + 'README').read.should.include 'Added!'
end end
end end
...@@ -21,11 +21,31 @@ module SpecHelper ...@@ -21,11 +21,31 @@ module SpecHelper
alias_method :git_super, :git alias_method :git_super, :git
def git(repo, command) 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 end
def git_config(repo, attr) def git_config(repo, attr)
git repo, "config --get #{attr}" git repo, "config --get #{attr}"
end 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
end end
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
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
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