Commit dc5b15a5 authored by Eloy Duran's avatar Eloy Duran

Make all not-disabled specs green again. Also introduces the `pod install --no-integrate` option.

parent 1db64746
......@@ -6,7 +6,7 @@ process do |files|
specs = files.take_and_map do |file|
if file =~ %r{lib/cocoapods/(.+?)\.rb$}
s = Dir.glob("spec/**/#{File.basename(file, '.rb')}_spec.rb")
if file =~ %r{lib/cocoapods/installer.+\.rb$}
if file =~ %r{lib/cocoapods/installer.*\.rb$}
s.concat(['spec/unit/installer_spec.rb', 'spec/unit/installer/target_installer_spec.rb'])
end
s.uniq unless s.empty?
......
......@@ -6,3 +6,4 @@
* Validate that the dependencies in the targets don't conflict. E.g. two different versions of the same pod.
* Move Podfile.lock generator from Installer into its own file.
* Remove better_installer.rb file
* One or more of the specs are changing the remote URL of the master repo in ~/.cocoapods
......@@ -24,9 +24,10 @@ module Pod
end
def self.options
" --no-clean Leave SCM dirs like `.git' and `.svn' intact after downloading\n" +
" --no-clean Leave SCM dirs like `.git' and `.svn' in tact after downloading\n" +
" --no-doc Skip documentation generation with appledoc\n" +
" --force-doc Force the generation of documentation\n" +
" --no-integrate Skip integration of the Pods libraries in the Xcode project(s)\n" +
" --no-update Skip running `pod repo update` before install\n" +
super
end
......@@ -35,6 +36,7 @@ module Pod
config.clean = !argv.option('--no-clean')
config.doc = !argv.option('--no-doc')
config.force_doc = argv.option('--force-doc')
config.integrate_targets = !argv.option('--no-integrate')
@update_repo = !argv.option('--no-update')
super unless argv.empty?
end
......@@ -44,8 +46,9 @@ module Pod
raise Informative, "No `Podfile' found in the current working directory."
end
if config.integrate_targets?
# TODO this should be done for all targets (?)
if xcodeproj = podfile.target_definitions[:default].xcodeproj
unless xcodeproj = podfile.target_definitions[:default].xcodeproj
raise Informative, "Please specify a valid xcodeproj path in your Podfile.\n\n" +
"Usage:\n\t" +
"xcodeproj 'path/to/project.xcodeproj'"
......@@ -54,6 +57,7 @@ module Pod
if xcodeproj && !xcodeproj.exist?
raise Informative, "The specified project `#{xcodeproj}' does not exist."
end
end
if @update_repo
puts "\nUpdating Spec Repositories\n".yellow if config.verbose?
......
......@@ -10,18 +10,19 @@ module Pod
@instance = instance
end
attr_accessor :repos_dir, :project_root, :project_pods_root, :clean, :verbose, :silent, :doc, :doc_install, :force_doc
attr_accessor :repos_dir, :project_root, :project_pods_root, :clean, :verbose, :silent, :doc, :doc_install, :force_doc, :integrate_targets
alias_method :clean?, :clean
alias_method :verbose?, :verbose
alias_method :silent?, :silent
alias_method :doc?, :doc
alias_method :doc?, :doc # TODO rename to generate_docs?
alias_method :doc_install?, :doc_install
alias_method :force_doc?, :force_doc
alias_method :integrate_targets?, :integrate_targets
def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods"))
@verbose = @silent = @force_doc = false
@clean = @doc = @doc_install = true
@clean = @doc = @doc_install = @integrate_targets = true
end
def project_root
......
......@@ -91,8 +91,7 @@ module Pod
puts "* Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose?
project.save_as(@sandbox.project_path)
# The conditional is actually only so we omit the integration when running the specs.
UserProjectIntegrator.new(@podfile).integrate! if @podfile.xcodeproj(false)
UserProjectIntegrator.new(@podfile).integrate! if config.integrate_targets?
end
def run_post_install_hooks
......
......@@ -86,13 +86,15 @@ module Pod
def targets
@targets ||= begin
if link_with = @target_definition.link_with
# Find explicitly named targets.
user_project.targets.select do |target|
link_with.include? target.name
end
else
# Default to the first, which in a simple project is probably an app target.
[user_project.targets.first]
end.reject do |target|
# reject any target that already has this Pods library in one of its frameworks build phases
# Reject any target that already has this Pods library in one of its frameworks build phases
target.frameworks_build_phases.any? do |phase|
phase.files.any? { |file| file.name == @target_definition.lib_name }
end
......
......@@ -39,7 +39,7 @@ describe Pod::Installer::UserProjectIntegrator do
it 'adds the project being integrated to the workspace' do
workspace = Xcodeproj::Workspace.new_from_xcworkspace(@sample_project_path.dirname + "SampleProject.xcworkspace")
workspace.should.include?("SampleProject.xcodeproj")
workspace.projpaths.sort.should == %w{ Pods/Pods.xcodeproj SampleProject.xcodeproj }
end
it 'adds the Pods project to the workspace' do
......@@ -82,22 +82,27 @@ describe Pod::Installer::UserProjectIntegrator do
end
end
before do
# Reset the cached TargetIntegrator#targets lists.
@integrator.instance_variable_set(:@target_integrators, nil)
end
it "only tries to integrate Pods libraries into user targets that haven't been integrated yet" do
app, test_runner = @integrator.target_integrators.first.user_project.targets.to_a
p app.frameworks_build_phases.first.files
test_runner.frameworks_build_phases.first.build_files.last.destroy
#p app, test_runner
app_integrator = @integrator.target_integrators.find { |t| t.target_definition.name == :default }
test_runner_integrator = @integrator.target_integrators.find { |t| t.target_definition.name == :test_runner }
# Remove libPods.a from the app target. But don't do it through TargetIntegrator#targets,
# as it will return only those that still need integration.
app_target = app_integrator.user_project.targets.where(:name => 'SampleProject')
app_target.frameworks_build_phases.first.build_files.last.destroy
target_integrators = @integrator.target_integrators.sort_by { |target| target.target_definition.label }
@integrator.stubs(:target_integrators).returns(target_integrators)
#p target_integrators
app_integrator.expects(:add_pods_library)
test_runner_integrator.expects(:add_pods_library).never
target_integrators.first.expects(:add_pods_library).never
target_integrators.last.expects(:add_pods_library)
@integrator.integrate!
end
xit "does not even try to save the project if none of the target integrators had any work to do" do
it "does not even try to save the project if none of the target integrators had any work to do" do
@integrator.target_integrators.first.user_project.expects(:save_as).never
@integrator.integrate!
end
......
......@@ -37,6 +37,7 @@ else
config.repos_dir = fixture('spec-repos')
config.project_root = temporary_directory
config.doc_install = false
config.integrate_targets = false
end
before do
......@@ -364,6 +365,8 @@ else
end
it "sets up an existing project with pods" do
config.integrate_targets = true
basename = platform == :ios ? 'iPhone' : 'Mac'
projpath = temporary_directory + 'ASIHTTPRequest.xcodeproj'
FileUtils.cp_r(fixture("integration/ASIHTTPRequest/#{basename}.xcodeproj"), projpath)
......
......@@ -36,12 +36,16 @@ describe "Pod::Command::Install" do
describe "When the Podfile specifies xcodeproj to an invalid path" do
before do
config.stubs(:podfile).returns(Pod::Podfile.new { platform :ios; xcodeproj 'nonexistent/project.xcodeproj'; dependency 'AFNetworking'})
config.stubs(:podfile).returns(Pod::Podfile.new do
platform :ios
xcodeproj 'nonexistent/project.xcodeproj'
dependency 'AFNetworking'
end)
@installer = Pod::Command::Install.new(Pod::Command::ARGV.new)
end
it "raises an informative error" do
should.raise(Pod::Informative) {@installer.run}
should.raise(Pod::Informative) { @installer.run }
end
it "should include an informative message" 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