Commit d1ef7c73 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Fix for master repo update & small performance improvements.

parent dc84ad04
...@@ -82,7 +82,7 @@ module Pod ...@@ -82,7 +82,7 @@ module Pod
lint_argv = ["lint"] lint_argv = ["lint"]
lint_argv << "--only-errors" if @allow_warnings lint_argv << "--only-errors" if @allow_warnings
lint_argv << "--silent" if config.silent lint_argv << "--silent" if config.silent
all_valid = true # all_valid = true
podspec_files.each do |podspec| podspec_files.each do |podspec|
Spec.new(ARGV.new(lint_argv + [podspec.to_s])).run Spec.new(ARGV.new(lint_argv + [podspec.to_s])).run
end end
......
...@@ -153,6 +153,8 @@ module Pod ...@@ -153,6 +153,8 @@ module Pod
is_compatilbe(versions) is_compatilbe(versions)
end end
#--------------------------------------#
private private
def versions(dir) def versions(dir)
......
...@@ -8,7 +8,6 @@ Pod::Spec.new do |s| ...@@ -8,7 +8,6 @@ Pod::Spec.new do |s|
s.source = { :git => 'http://banana-corp.local/banana-lib.git', :tag => 'v1.0' } s.source = { :git => 'http://banana-corp.local/banana-lib.git', :tag => 'v1.0' }
s.source_files = 'Classes/*.{h,m}', 'Vendor' s.source_files = 'Classes/*.{h,m}', 'Vendor'
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' } s.xcconfig = { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' }
s.clean_paths = "sub-dir"
s.prefix_header_file = 'Classes/BananaLib.pch' s.prefix_header_file = 'Classes/BananaLib.pch'
s.resources = "Resources/*.png" s.resources = "Resources/*.png"
s.dependency 'monkey', '~> 1.0.1', '< 1.0.9' s.dependency 'monkey', '~> 1.0.1', '< 1.0.9'
......
...@@ -2,41 +2,36 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,41 +2,36 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::List" do describe "Pod::Command::List" do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
extend SpecHelper::TemporaryDirectory
def command(arguments = argv) def command(arguments = argv)
command = Pod::Command::List.new(arguments) command = Pod::Command::List.new(arguments)
end end
it "complains for wrong parameters" do before do
lambda { command(argv('wrong')).run }.should.raise Pod::Command::Help set_up_test_repo
lambda { command(argv('--wrong')).run }.should.raise Pod::Command::Help config.repos_dir = SpecHelper.tmp_repos_path
end end
it "presents the known pods" do it "presents the known pods" do
list = command() command.run
list.run Pod::UI.output
[ /ZBarSDK/, [ /BananaLib/,
/TouchJSON/, /JSONKit/,
/SDURLCache/,
/MagicalRecord/,
/A2DynamicDelegate/,
/\d+ pods were found/ /\d+ pods were found/
].each { |regex| Pod::UI.output.should =~ regex } ].each { |regex| Pod::UI.output.should =~ regex }
end end
it "returns the new pods" do it "returns the new pods" do
Time.stubs(:now).returns(Time.mktime(2012,2,3)) sets = Pod::Source.all_sets
list = command(argv('new')) jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
list.run dates = {
[ 'iCarousel', 'BananaLib' => Time.now,
'libPusher', 'JSONKit' => Time.parse('01/01/1970') }
'SSCheckBoxView', Pod::Specification::Statistics.any_instance.stubs(:creation_dates).returns(dates)
'KKPasscodeLock', command(argv('new')).run
'SOCKit', Pod::UI.output.should.include('BananaLib')
'FileMD5Hash', Pod::UI.output.should.not.include('JSONKit')
'cocoa-oauth',
'iRate'
].each {|s| Pod::UI.output.should.include s }
end end
end end
......
...@@ -9,72 +9,70 @@ describe Pod::Command::Push do ...@@ -9,72 +9,70 @@ describe Pod::Command::Push do
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
def master_repo
fixture('spec-repos/master')
end
it "complains for wrong parameters" do
lambda { run_command('push') }.should.raise Pod::Command::Help
lambda { run_command('push', '--allow-warnings') }.should.raise Pod::Command::Help
lambda { run_command('push', '--wrong-option') }.should.raise Pod::Command::Help
end
it "complains if it can't find the repo" do it "complains if it can't find the repo" do
repo1 = add_repo('repo1', master_repo)
Dir.chdir(fixture('banana-lib')) do Dir.chdir(fixture('banana-lib')) do
lambda { run_command('push', 'repo2') }.should.raise Pod::Informative cmd = command('push', 'missing_repo')
cmd.expects(:validate_podspec_files).returns(true)
e = lambda { cmd.run }.should.raise Pod::Informative
e.message.should.match(/repo not found/)
end end
end end
it "complains if it can't find a spec" do it "complains if it can't find a spec" do
repo1 = add_repo('repo1', master_repo) repo_make('test_repo')
lambda { run_command('push', 'repo1') }.should.raise Pod::Informative e = lambda { run_command('push', 'test_repo') }.should.raise Pod::Informative
e.message.should.match(/Couldn't find any .podspec/)
end end
it "it raises if the pod is not validated" do # TODO: the validation should not use the pod spec command
repo1 = add_repo('repo1', master_repo) xit "it raises if the specification doesn't validates" do
repo2 = add_repo('repo2', repo1.dir) repo_make('test_repo')
git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s Dir.chdir(temporary_directory) do
Dir.chdir(fixture('banana-lib')) do spec = "Spec.new do |s|; s.name = 'Broken'; end"
lambda { command('push', 'repo2', '--silent').run }.should.raise Pod::Informative File.open('Broken.podspec', 'w') {|f| f.write(spec) }
cmd = command('push', 'test_repo')
cmd.expects(:validate_podspec_files).returns(true)
e = lambda { cmd.run }.should.raise Pod::Informative
e.message.should.match(/repo not clean/)
end end
# (repo1.dir + 'BananaLib/1.0/BananaLib.podspec').read.should.include 'Added!'
end end
before do before do
# prepare the repos repo_make('upstream')
@upstream = add_repo('upstream', master_repo) repo_clone('upstream', 'local_repo')
@local_repo = add_repo('local_repo', @upstream.dir)
git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s
# prepare the spec # prepare the spec
spec = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read spec = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read
spec_fix = spec.gsub(/https:\/\/github\.com\/johnezang\/JSONKit\.git/, fixture('integration/JSONKit').to_s) spec_fix = spec.gsub(/https:\/\/github\.com\/johnezang\/JSONKit\.git/, fixture('integration/JSONKit').to_s)
spec_add = spec.gsub(/'JSONKit'/, "'PushTest'") spec_add = spec.gsub(/'JSONKit'/, "'PushTest'")
File.open(temporary_directory + 'JSONKit.podspec', 'w') {|f| f.write(spec_fix) } File.open(temporary_directory + 'JSONKit.podspec', 'w') {|f| f.write(spec_fix) }
File.open(temporary_directory + 'PushTest.podspec', 'w') {|f| f.write(spec_add) } File.open(temporary_directory + 'PushTest.podspec', 'w') {|f| f.write(spec_add) }
end end
it "refuses to push if the repo is not clean" do it "refuses to push if the repo is not clean" do
File.open(@local_repo.dir + 'README', 'w') {|f| f.write('Added!') } repo_make_readme_change('local_repo', 'dirty')
(@local_repo.dir + 'README').read.should.include 'Added!' Dir.chdir(temporary_directory) do
cmd = command('push', 'local_repo') cmd = command('push', 'local_repo')
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { lambda { cmd.run }.should.raise Pod::Informative } e = lambda { cmd.run }.should.raise Pod::Informative
e.message.should.match(/repo not clean/)
(@upstream.dir + 'PushTest/1.4/PushTest.podspec').should.not.exist? end
(repo_path('upstream') + 'PushTest/1.4/PushTest.podspec').should.not.exist?
end end
it "sucessfully pushes a spec" do it "sucessfully pushes a spec" do
git('upstream', 'checkout master') # checkout master, to allow push in a non-bare repository
cmd = command('push', 'local_repo') cmd = command('push', 'local_repo')
Dir.chdir(repo_path 'upstream') { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run } Dir.chdir(temporary_directory) { cmd.run }
Pod::UI.output.should.include('[Add] PushTest (1.4)') Pod::UI.output.should.include('[Add] PushTest (1.4)')
Pod::UI.output.should.include('[Fix] JSONKit (1.4)') Pod::UI.output.should.include('[Add] JSONKit (1.4)')
# TODO check the commit messages
# Pod::UI.output.should.include('[Fix] JSONKit (1.4)')
git('upstream', 'checkout test') # checkout because test because is it the branch used in the specs. Dir.chdir(repo_path 'upstream') { `git checkout master -q` }
(@upstream.dir + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest') (repo_path('upstream') + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest')
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Repo" do module Pod
describe Command::Repo do
before do describe "In general" do
config.repos_dir = SpecHelper.tmp_repos_path extend SpecHelper::Command
end extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
describe "In general" do
extend SpecHelper::Command before do
extend SpecHelper::TemporaryDirectory set_up_test_repo
extend SpecHelper::TemporaryRepos config.repos_dir = SpecHelper.tmp_repos_path
end
it "runs with correct parameters" do
lambda { run_command('repo', 'update') }.should.not.raise
lambda { run_command('repo', 'lint', temporary_directory.to_s) }.should.not.raise
end
it "complains for wrong parameters" do
lambda { run_command('repo', 'add') }.should.raise Pod::Informative
lambda { run_command('repo', 'add', 'NAME') }.should.raise Pod::Informative
end
it "adds a spec-repo" do it "updates a repository" do
run_command('repo', 'add', 'private', fixture('spec-repos/master')) upstream = SpecHelper.temporary_directory + 'upstream'
git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s FileUtils.cp_r(test_repo_path, upstream)
end Dir.chdir(test_repo_path) do
`git remote add origin #{upstream}`
`git remote -v`
`git fetch -q`
`git branch --set-upstream master origin/master`
end
lambda { command('repo', 'update').run }.should.not.raise
end
it "adds a spec-repo with on a specified branch" do it "lints a repository" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) lambda { run_command('repo', 'lint', temporary_directory.to_s) }.should.not.raise
Dir.chdir(repo1.dir) do
`git checkout -b my-branch >/dev/null 2>&1`
`git checkout master >/dev/null 2>&1`
end end
repo2 = command( 'repo' ,'add', 'repo2', repo1.dir, 'my-branch')
repo2.run
Dir.chdir(repo2.dir) { `git symbolic-ref HEAD` }.should.include? 'my-branch'
end
it "updates a spec-repo" do it "complains for wrong parameters" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) lambda { run_command('repo', 'add') }.should.raise Informative
repo2 = add_repo('repo2', repo1.dir) lambda { run_command('repo', 'add', 'NAME') }.should.raise Informative
make_change(repo1, 'repo1') end
run_command('repo', 'update', 'repo2')
(repo2.dir + 'README').read.should.include 'Added!'
end
it "updates all the spec-repos" do it "adds a spec-repo" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) run_command('repo', 'add', 'private', test_repo_path)
repo2 = add_repo('repo2', repo1.dir) Dir.chdir(config.repos_dir + 'private') do
repo3 = add_repo('repo3', repo1.dir) `git config --get remote.origin.url`.chomp.should == test_repo_path.to_s
make_change(repo1, 'repo1') end
run_command('repo', 'update') end
(repo2.dir + 'README').read.should.include 'Added!'
(repo3.dir + 'README').read.should.include 'Added!'
end
before do it "adds a spec-repo with a specified branch" do
config.repos_dir = fixture('spec-repos') repo1 = repo_make('repo1')
end Dir.chdir(repo1) do
`git checkout -b my-branch >/dev/null 2>&1`
`git checkout master >/dev/null 2>&1`
end
repo2 = command( 'repo' ,'add', 'repo2', repo1.to_s, 'my-branch')
repo2.run
Dir.chdir(repo2.dir) { `git symbolic-ref HEAD` }.should.include? 'my-branch'
end
it "lints a repo" do it "updates a spec-repo" do
cmd = command('repo', 'lint', 'master') repo1 = repo_make('repo1')
lambda { cmd.run }.should.raise Pod::Informative repo2 = repo_clone('repo1', 'repo2')
Pod::UI.output.should.include "Missing license type" repo_make_readme_change(repo1, 'Updated')
Dir.chdir(repo1) {`git commit -a -m "Update"`}
run_command('repo', 'update', 'repo2')
(repo2 + 'README').read.should.include 'Updated'
end
end end
end
describe "Concerning a repo support" do describe "CocoaPods version" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
before do require 'yaml'
add_repo('repo1', fixture('spec-repos/master'))
FileUtils.rm_rf(versions_file)
versions_file.should.not.exist?
end
require 'yaml' before do
config.repos_dir = SpecHelper.tmp_repos_path
def versions_file @repo = repo_make('repo1')
tmp_repos_path + "repo1/CocoaPods-version.yml" end
end
def write_version_file(hash) def write_version_file(hash)
yaml = YAML.dump(hash) yaml = YAML.dump(hash)
File.open(versions_file, 'w') {|f| f.write(yaml) } @versions_file = tmp_repos_path + "repo1/CocoaPods-version.yml"
end File.open(@versions_file, 'w') {|f| f.write(yaml) }
end
it "it doesn't requires CocoaPods-version.yml" do it "it doesn't requires CocoaPods-version.yml" do
cmd = command('repo', 'update') cmd = command('repo', 'update')
lambda { cmd.check_versions(versions_file.dirname) }.should.not.raise lambda { cmd.check_versions(@repo) }.should.not.raise
end end
it "runs with a compatible repo" do it "runs with a compatible repo" do
write_version_file({'min' => "0.0.1"}) write_version_file({'min' => "0.0.1"})
cmd = command('repo', 'update') cmd = command('repo', 'update')
lambda { cmd.check_versions(versions_file.dirname) }.should.not.raise lambda { cmd.check_versions(@repo) }.should.not.raise
end end
it "raises if a repo is not compatible" do it "raises if a repo is not compatible" do
write_version_file({'min' => "999.0.0"}) write_version_file({'min' => "999.0.0"})
cmd = command('repo', 'update') cmd = command('repo', 'update')
lambda { cmd.check_versions(versions_file.dirname) }.should.raise Pod::Informative lambda { cmd.check_versions(@repo) }.should.raise Informative
end end
it "informs about a higher known CocoaPods version" do it "informs about a higher known CocoaPods version" do
write_version_file({'last' => "999.0.0"}) write_version_file({'last' => "999.0.0"})
cmd = command('repo', 'update') cmd = command('repo', 'update')
cmd.check_versions(versions_file.dirname) cmd.check_versions(@repo)
Pod::UI.output.should.include "Cocoapods 999.0.0 is available" UI.output.should.include "Cocoapods 999.0.0 is available"
end end
it "has a class method that returns if a repo is supported" do it "has a class method that returns if a repo is supported" do
write_version_file({'min' => "999.0.0"}) write_version_file({'min' => "999.0.0"})
Pod::Command::Repo.compatible?('repo1').should == false Command::Repo.compatible?('repo1').should == false
write_version_file({'min' => "0.0.1"}) write_version_file({'min' => "0.0.1"})
Pod::Command::Repo.compatible?('repo1').should == true Command::Repo.compatible?('repo1').should == true
end
end end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Setup" do describe Pod::Command::Setup do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
...@@ -10,16 +10,7 @@ describe "Pod::Command::Setup" do ...@@ -10,16 +10,7 @@ describe "Pod::Command::Setup" do
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "runs with correct parameters" do it "returns the read only URL of the `master` spec-repo" do
lambda { run_command('setup') }.should.not.raise
end
it "complains for wrong parameters" do
lambda { run_command('setup', 'wrong') }.should.raise Pod::Command::Help
lambda { run_command('setup', '--wrong') }.should.raise Pod::Command::Help
end
it "returns the read only URL of the `master' spec-repo" do
cmd = Pod::Command::Setup.new(argv) cmd = Pod::Command::Setup.new(argv)
cmd.url.should == 'https://github.com/CocoaPods/Specs.git' cmd.url.should == 'https://github.com/CocoaPods/Specs.git'
end end
...@@ -30,21 +21,33 @@ describe "Pod::Command::Setup" do ...@@ -30,21 +21,33 @@ describe "Pod::Command::Setup" do
cmd.url.should == 'git@github.com:CocoaPods/Specs.git' cmd.url.should == 'git@github.com:CocoaPods/Specs.git'
end end
class Pod::Command::Setup before do
def read_only_url; SpecHelper.fixture('spec-repos/master'); end set_up_test_repo
Pod::Command::Setup.any_instance.stubs(:read_only_url).returns(test_repo_path.to_s)
config.repos_dir = SpecHelper.temporary_directory
end
it "runs with correct parameters" do
lambda { run_command('setup') }.should.not.raise
end
it "complains for wrong parameters" do
lambda { run_command('setup', 'wrong') }.should.raise Pod::Command::Help
lambda { run_command('setup', '--wrong') }.should.raise Pod::Command::Help
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
output = run_command('setup') output = run_command('setup')
output.should.include "Setup completed" output.should.include "Setup completed"
output.should.not.include "push" output.should.not.include "push"
git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s url = Dir.chdir(config.repos_dir + 'master') { `git config --get remote.origin.url`.chomp }
url.should == test_repo_path.to_s
end end
it "preserves push access for the `master' repo" do it "preserves push access for the `master' repo" do
output = run_command('setup') output = run_command('setup')
output.should.not.include "push" output.should.not.include "push"
git('master', 'remote set-url origin git@github.com:CocoaPods/Specs.git') Dir.chdir(config.repos_dir + 'master') { `git remote set-url origin git@github.com:CocoaPods/Specs.git` }
command('setup').url.should == 'git@github.com:CocoaPods/Specs.git' command('setup').url.should == 'git@github.com:CocoaPods/Specs.git'
end end
......
...@@ -15,17 +15,12 @@ describe Pod::UI do ...@@ -15,17 +15,12 @@ describe Pod::UI do
output.should.include? 'CocoaLumberjack' output.should.include? 'CocoaLumberjack'
output.should.include? '1.0' output.should.include? '1.0'
output.should.include? '1.1' output.should.include? '1.1'
output.should.include? '[master repo]'
output.should.include? 'A fast & simple, yet powerful & flexible logging framework for Mac and iOS.' output.should.include? 'A fast & simple, yet powerful & flexible logging framework for Mac and iOS.'
output.should.include? 'https://github.com/robbiehanson/CocoaLumberjack' output.should.include? 'https://github.com/robbiehanson/CocoaLumberjack'
output.should.include? 'https://github.com/robbiehanson/CocoaLumberjack.git' output.should.include? 'https://github.com/robbiehanson/CocoaLumberjack.git'
end end
it "presents the name, version, description, homepage and source of a specification set" do
Pod::UI.pod(@set)
output = Pod::UI.output
output.should.include? 'Versions: 1.6, 1.3.3, 1.3.2, 1.3.1, 1.3, 1.2.3, 1.2.2, 1.2.1, 1.2, 1.1, 1.0 [master repo]'
end
it "presents the stats of a specification set" do it "presents the stats of a specification set" do
repo = { "forks"=>42, "watchers"=>318, "pushed_at"=>"2011-01-26T19:06:43Z" } repo = { "forks"=>42, "watchers"=>318, "pushed_at"=>"2011-01-26T19:06:43Z" }
Octokit.expects(:repo).with("robbiehanson/CocoaLumberjack").returns(repo) Octokit.expects(:repo).with("robbiehanson/CocoaLumberjack").returns(repo)
......
...@@ -196,15 +196,19 @@ else ...@@ -196,15 +196,19 @@ else
result = installer.lockfile.to_hash result = installer.lockfile.to_hash
result['PODS'].should == [ result['PODS'].should == [
{ "ASIHTTPRequest (1.8.1)" => ["ASIHTTPRequest/ASIWebPageRequest (= 1.8.1)", { "ASIHTTPRequest (1.8.1)" =>
"ASIHTTPRequest/CloudFiles (= 1.8.1)", [ "ASIHTTPRequest/ASIWebPageRequest (= 1.8.1)",
"ASIHTTPRequest/S3 (= 1.8.1)", "ASIHTTPRequest/CloudFiles (= 1.8.1)",
"Reachability"]}, "ASIHTTPRequest/S3 (= 1.8.1)",
{ "ASIHTTPRequest/ASIWebPageRequest (1.8.1)" => ["Reachability"] }, "Reachability"
{ "ASIHTTPRequest/CloudFiles (1.8.1)" => ["Reachability"] }, ]
{ "ASIHTTPRequest/S3 (1.8.1)" => ["Reachability"] }, },
"JSONKit (1.4)", { "ASIHTTPRequest/ASIWebPageRequest (1.8.1)" => ["Reachability"] },
"Reachability (3.0.0)"] { "ASIHTTPRequest/CloudFiles (1.8.1)" => ["Reachability"] },
{ "ASIHTTPRequest/S3 (1.8.1)" => ["Reachability"] },
"JSONKit (1.4)",
"Reachability (3.1.0)"
]
result['DEPENDENCIES'].should == ["ASIHTTPRequest", "JSONKit (= 1.4)"] result['DEPENDENCIES'].should == ["ASIHTTPRequest", "JSONKit (= 1.4)"]
# TODO might be nicer looking to not show the dependencies of the top level spec for each subspec (Reachability). # TODO might be nicer looking to not show the dependencies of the top level spec for each subspec (Reachability).
...@@ -304,7 +308,7 @@ else ...@@ -304,7 +308,7 @@ else
lockfile_contents = { lockfile_contents = {
'PODS' => [ 'PODS' => [
'JSONKit (999.999.999)', 'JSONKit (999.999.999)',
'Reachability (3.0.0)', 'Reachability (3.1.0)',
'SSZipArchive (0.1.1)', 'SSZipArchive (0.1.1)',
], ],
'DEPENDENCIES' => [ 'DEPENDENCIES' => [
......
require 'spec_helper/temporary_directory' require 'spec_helper/temporary_directory'
# Important
# Include with temporary directory
module SpecHelper module SpecHelper
def self.tmp_repos_path def self.tmp_repos_path
TemporaryRepos.tmp_repos_path TemporaryRepos.tmp_repos_path
...@@ -9,41 +12,64 @@ module SpecHelper ...@@ -9,41 +12,64 @@ module SpecHelper
extend Pod::Executable extend Pod::Executable
executable :git executable :git
def tmp_repos_path # @return [Pathname] The path for the repo with the given name.
SpecHelper.temporary_directory + 'cocoapods' #
def repo_path(name)
tmp_repos_path + name
end end
module_function :tmp_repos_path
alias_method :git_super, :git # Makes a repo with the given name.
def git(repo, command) #
Dir.chdir(tmp_repos_path + repo) do def repo_make(name)
if output = git_super(command) path = repo_path(name)
output.strip path.mkpath
end Dir.chdir(path) do
`git init`
repo_make_readme_change(name, 'Added')
`git add .`
`git commit -m "Initialized."`
end end
path
end end
def git_config(repo, attr) # Clones a repo to the given name.
git repo, "config --get #{attr}" #
def repo_clone(from_name, to_name)
Dir.chdir(tmp_repos_path) { `git clone #{from_name} #{to_name}` }
repo_path(to_name)
end end
def add_repo(name, from) def repo_make_readme_change(name, string)
command = command('repo', 'add', name, from) file = repo_path(name) + 'README'
command.run file.open('w') { |f| f << "#{string}" }
# The test branch is used by the push specs end
Dir.chdir(command.dir) do
`git checkout -b test >/dev/null 2>&1` #--------------------------------------#
`git branch --set-upstream test origin/master >/dev/null 2>&1`
end def test_repo_path
command repo_path('master')
end end
def make_change(repo, name) # Sets up a lighweight master repo in `tmp/cocoapods/master` with the
(repo.dir + 'README').open('w') { |f| f << 'Added!' } # contents of `spec/fixtures/spec-repos/test_repo`.
git(name, 'add README') #
git(name, 'commit -m "changed"') def set_up_test_repo
require 'fileutils'
test_repo_path.mkpath
origin = ROOT + 'spec/fixtures/spec-repos/test_repo/.'
destination = tmp_repos_path + 'master'
FileUtils.cp_r(origin, destination)
repo_make('master')
end end
#--------------------------------------#
def tmp_repos_path
SpecHelper.temporary_directory + 'cocoapods'
end
module_function :tmp_repos_path
def self.extended(base) def self.extended(base)
base.before do base.before do
tmp_repos_path.mkpath tmp_repos_path.mkpath
......
...@@ -5,8 +5,8 @@ module Pod ...@@ -5,8 +5,8 @@ module Pod
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios, '6.0'
pod 'BlocksKit' pod 'BlocksKit', '1.8.0'
end end
@resolver = Resolver.new(@podfile, nil, stub('sandbox')) @resolver = Resolver.new(@podfile, nil, stub('sandbox'))
end end
...@@ -14,7 +14,6 @@ module Pod ...@@ -14,7 +14,6 @@ module Pod
it "holds the context state, such as cached specification sets" do it "holds the context state, such as cached specification sets" do
@resolver.resolve @resolver.resolve
@resolver.cached_sets.values.sort_by(&:name).should == [ @resolver.cached_sets.values.sort_by(&:name).should == [
Pod::Source.search_by_name('A2DynamicDelegate').first,
Pod::Source.search_by_name('BlocksKit').first, Pod::Source.search_by_name('BlocksKit').first,
Pod::Source.search_by_name('libffi').first Pod::Source.search_by_name('libffi').first
].sort_by(&:name) ].sort_by(&:name)
...@@ -23,13 +22,13 @@ module Pod ...@@ -23,13 +22,13 @@ module Pod
it "returns all specs needed for the dependency" do it "returns all specs needed for the dependency" do
specs = @resolver.resolve.values.flatten specs = @resolver.resolve.values.flatten
specs.map(&:class).uniq.should == [Specification] specs.map(&:class).uniq.should == [Specification]
specs.map(&:name).sort.should == %w{ A2DynamicDelegate BlocksKit libffi } specs.map(&:name).sort.should == %w{ BlocksKit libffi }
end end
it "does not raise if all dependencies match the platform of the root spec (Podfile)" do it "does not raise if all dependencies match the platform of the root spec (Podfile)" do
@podfile.platform :ios @podfile.platform :ios, '6.0'
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
@podfile.platform :osx @podfile.platform :osx, '10.7'
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
end end
...@@ -259,7 +258,7 @@ module Pod ...@@ -259,7 +258,7 @@ module Pod
platform :ios platform :ios
pod 'JSONKit' pod 'JSONKit'
pod 'BlocksKit' pod 'BlocksKit'
pod 'libPusher' # New pod pod 'libPusher', '1.3' # New pod
end end
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
installed = @resolver.resolve.values.flatten.map(&:to_s) installed = @resolver.resolve.values.flatten.map(&:to_s)
...@@ -348,7 +347,7 @@ module Pod ...@@ -348,7 +347,7 @@ module Pod
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios, '6.0'
pod 'BlocksKit' pod 'BlocksKit'
pod 'JSONKit' pod 'JSONKit'
pod 'libPusher' pod 'libPusher'
...@@ -376,7 +375,7 @@ module Pod ...@@ -376,7 +375,7 @@ module Pod
it "respects the constraints of the podfile" do it "respects the constraints of the podfile" do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios, '6.0'
pod 'BlocksKit' pod 'BlocksKit'
pod 'JSONKit', '1.4' pod 'JSONKit', '1.4'
end end
......
...@@ -16,7 +16,9 @@ describe "Pod::Source" do ...@@ -16,7 +16,9 @@ describe "Pod::Source" do
end end
it "returns the available versions of a Pod" do it "returns the available versions of a Pod" do
@source.versions('Reachability').map(&:to_s).should == %w| 3.0.0 2.0.5 2.0.4 | known = %w| 3.0.0 2.0.5 2.0.4 |
computed = @source.versions('Reachability').map(&:to_s)
(known - computed).should.be.empty?
end end
it "returns the specification of a given version of a Pod" do it "returns the specification of a given version of a Pod" do
......
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