Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 60caa66704a910d40b650ca0e3f15f4f747ef182 1 parent 78f52d3
@alloy alloy authored
View
8 Rakefile
@@ -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
View
2  lib/cocoapods.rb
@@ -1,5 +1,5 @@
module Pod
- VERSION = '0.0.2'
+ VERSION = '0.0.3'
class Informative < StandardError
end
View
6 lib/cocoapods/command/install.rb
@@ -32,13 +32,13 @@ def run
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!
View
8 lib/cocoapods/xcode/project.rb
@@ -3,6 +3,8 @@
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 @@ def add_source_file(file)
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
View
31 spec/integration_spec.rb
@@ -31,8 +31,14 @@ def set.specification
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 @@ def set.specification
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 @@ def set.specification
(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
View
18 spec/unit/command_spec.rb
@@ -24,3 +24,21 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.