Commit 60caa667 authored by Eloy Duran's avatar Eloy Duran

Fix bug that would copy Pods.xcodeproj dir into existing one.

parent 78f52d3c
......@@ -10,3 +10,11 @@ task :clean do
sh "rm -f lib/**/*.rbo"
sh "rm -f *.gem"
end
desc "Install a gem version of the current code"
task :install do
require 'lib/cocoapods'
sh "gem build cocoapods.gemspec"
sh "sudo macgem install cocoapods-#{Pod::VERSION}.gem"
sh "sudo macgem compile cocoapods"
end
module Pod
VERSION = '0.0.2'
VERSION = '0.0.3'
class Informative < StandardError
end
......
......@@ -32,13 +32,13 @@ module Pod
if @podspec.exist?
spec = Specification.from_podspec(@podspec)
else
raise Help, "The specified podspec `#{@podspec}' doesn't exist."
raise Informative, "The specified podspec `#{@podspec}' doesn't exist."
end
else
if config.project_podfile.exist?
if config.project_podfile
spec = Specification.from_podfile(config.project_podfile)
else
raise Help, "No Podfile found in current working directory."
raise Informative, "No `Podfile' or `.podspec' file found in the current working directory."
end
end
Installer.new(spec).install!
......
......@@ -3,6 +3,8 @@ framework 'Foundation'
module Pod
module Xcode
class Project
include Pod::Config::Mixin
# TODO this is a workaround for an issue with MacRuby with compiled files
# that makes the use of __FILE__ impossible.
#
......@@ -62,10 +64,10 @@ module Pod
end
def create_in(pods_root)
@template_dir.children.each do |child|
FileUtils.cp_r(child, pods_root + child.relative_path_from(@template_dir))
end
puts " * Copying contents of template directory `#{@template_dir}' to `#{pods_root}'" if config.verbose?
FileUtils.cp_r("#{@template_dir}/.", pods_root)
pbxproj = pods_root + template_file
puts " * Writing Xcode project file to `#{pbxproj}'" if config.verbose?
@template.writeToFile(pbxproj.to_s, atomically:true)
end
......
......@@ -31,8 +31,14 @@ else
Pod::Source.reset!
Pod::Spec::Set.reset!
fixture('spec-repos/master') # ensure the archive is unpacked
config.project_pods_root = temporary_directory + 'Pods'
config.repos_dir = fixture('spec-repos')
config.project_pods_root = temporary_directory + 'Pods'
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
Dir.chdir(config.project_pods_root.to_s) do
FileUtils.mv('ASIHTTPRequest', 'ASIHTTPRequest-1.8.1')
FileUtils.mv('JSONKit', 'JSONKit-1.4')
FileUtils.mv('SSZipArchive', 'SSZipArchive-1.0')
end
end
after do
......@@ -40,9 +46,10 @@ else
config.repos_dir = SpecHelper.tmp_repos_path
end
# TODO add a simple source file which uses the compiled lib to check that it really really works
it "should activate required pods and create a working static library xcode project" do
spec = Pod::Spec.new do
dependency 'ASIWebPageRequest', '< 1.8.1'
dependency 'ASIWebPageRequest', '>= 1.8.1'
dependency 'JSONKit', '>= 1.0'
dependency 'SSZipArchive', '< 2'
end
......@@ -79,5 +86,25 @@ else
(config.project_pods_root + 'Reachability.podspec').should.exist
(config.project_pods_root + 'ASIHTTPRequest.podspec').should.not.exist
end
# TODO we need to do more cleaning and/or add a --prune task
it "overwrites an existing project.pbxproj file" do
spec = Pod::Spec.new do
dependency 'JSONKit'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
Pod::Source.reset!
Pod::Spec::Set.reset!
spec = Pod::Spec.new do
dependency 'SSZipArchive'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
project = Pod::Xcode::Project.new(config.project_pods_root)
project.source_files.sort.should == Pod::Installer.new(spec).source_files.sort
end
end
end
......@@ -24,3 +24,21 @@ describe "Pod::Command::Repo" do
lambda { Pod::Command::Repo.new(argv('something')) }.should.raise Pod::Command::Help
end
end
describe "Pod::Command::Install" do
it "tells the user that the specified podspec file doesn't exist" do
command = Pod::Command::Install.new(argv('/does/not/exist/Some.podspec'))
exception = lambda {
command.run
}.should.raise Pod::Informative
exception.message.should.include "The specified podspec `/does/not/exist/Some.podspec' doesn't exist."
end
it "tells the user that no Podfile or podspec was found in the current working dir" do
command = Pod::Command::Install.new(argv)
exception = lambda {
command.run
}.should.raise Pod::Informative
exception.message.should.include "No `Podfile' or `.podspec' file found in the current working directory."
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