Commit cd5f5496 authored by Olivier Halligon's avatar Olivier Halligon

[📦] Fix unit tests

parent 0edfb80b
......@@ -9,6 +9,14 @@ module Pod
class TargetIntegrator
autoload :XCConfigIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator'
# @return [String] the PACKAGE emoji to use as prefix for every build phase aded to the user project
#
BUILD_PHASE_PREFIX = "\u{1F4E6} ".freeze
# @return [String] the name of the check manifest phase
#
CHECK_MANIFEST_PHASE_NAME = 'Check Pods Manifest.lock'.freeze
# @return [Array<Symbol>] the symbol types, which require that the pod
# frameworks are embedded in the output directory / product bundle.
#
......@@ -18,9 +26,9 @@ module Pod
#
EMBED_FRAMEWORK_PHASE_NAME = 'Embed Pods Frameworks'.freeze
# @return [String] the PACKAGE emoji to use as prefix for every build phase aded to the user project
# @return [String] the name of the copy resources phase
#
BUILD_PHASE_PREFIX = "\u{1F4E6} ".freeze
COPY_PODS_RESOURCES_PHASE_NAME = 'Copy Pods Resources'.freeze
# @return [AggregateTarget] the target that should be integrated.
#
......@@ -125,7 +133,7 @@ module Pod
# @return [void]
#
def add_copy_resources_script_phase
phase_name = 'Copy Pods Resources'
phase_name = COPY_PODS_RESOURCES_PHASE_NAME
native_targets.each do |native_target|
phase = create_or_update_build_phase(native_target, phase_name)
script_path = target.copy_resources_script_relative_path
......@@ -143,7 +151,7 @@ module Pod
# @return [void]
#
def add_check_manifest_lock_script_phase
phase_name = 'Check Pods Manifest.lock'
phase_name = CHECK_MANIFEST_PHASE_NAME
native_targets.each do |native_target|
phase = create_or_update_build_phase(native_target, phase_name)
native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase
......
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
CHECK_MANIFEST_PHASE_NAME = Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX +
Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME
EMBED_FRAMEWORK_PHASE_NAME = Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX +
Installer::UserProjectIntegrator::TargetIntegrator::EMBED_FRAMEWORK_PHASE_NAME
COPY_PODS_RESOURCES_PHASE_NAME = Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX +
Installer::UserProjectIntegrator::TargetIntegrator::COPY_PODS_RESOURCES_PHASE_NAME
describe TargetIntegrator = Installer::UserProjectIntegrator::TargetIntegrator do
describe 'In general' do
# The project contains a `PBXReferenceProxy` in the build files of the
......@@ -42,7 +49,7 @@ module Pod
it 'fixes the copy resource scripts of legacy installations' do
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Copy Pods Resources' }
phase = target.shell_script_build_phases.find { |bp| bp.name == COPY_PODS_RESOURCES_PHASE_NAME }
phase.shell_script = %("${SRCROOT}/../Pods/Pods-resources.sh"\n)
@target_integrator.integrate!
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh\""
......@@ -79,14 +86,14 @@ module Pod
it 'adds a Copy Pods Resources build phase to each target' do
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Copy Pods Resources' }
phase = target.shell_script_build_phases.find { |bp| bp.name == COPY_PODS_RESOURCES_PHASE_NAME }
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh\""
end
it 'adds a Check Manifest.lock build phase to each target' do
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Check Pods Manifest.lock' }
phase = target.shell_script_build_phases.find { |bp| bp.name == CHECK_MANIFEST_PHASE_NAME }
phase.shell_script.should == <<-EOS.strip_heredoc
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [[ $? != 0 ]] ; then
......@@ -102,7 +109,7 @@ module Pod
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
target.build_phases.first
phase = target.build_phases.find { |bp| bp.name == 'Check Pods Manifest.lock' }
phase = target.build_phases.find { |bp| bp.name == CHECK_MANIFEST_PHASE_NAME }
target.build_phases.first.should.equal? phase
end
......@@ -119,14 +126,14 @@ module Pod
@pod_bundle.stubs(:requires_frameworks? => true)
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
end
it 'adds an embed frameworks build phase by default' do
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
end
......@@ -135,7 +142,7 @@ module Pod
target = @target_integrator.send(:native_targets).first
target.stubs(:symbol_type).returns(:framework)
@target_integrator.integrate!
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == true
end
......@@ -144,7 +151,7 @@ module Pod
target = @target_integrator.send(:native_targets).first
target.stubs(:symbol_type).returns(:app_extension)
@target_integrator.integrate!
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
end
......@@ -153,7 +160,7 @@ module Pod
target = @target_integrator.send(:native_targets).first
target.stubs(:symbol_type).returns(:watch_extension)
@target_integrator.integrate!
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
end
......@@ -162,7 +169,7 @@ module Pod
target = @target_integrator.send(:native_targets).first
target.stubs(:symbol_type).returns(:watch2_extension)
@target_integrator.integrate!
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
end
......@@ -172,7 +179,7 @@ module Pod
@pod_bundle.stubs(:requires_frameworks? => false)
target = @target_integrator.send(:native_targets).first
@target_integrator.integrate!
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.should.not.be.nil
end
......@@ -182,7 +189,7 @@ module Pod
@pod_bundle.stubs(:requires_frameworks? => false)
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
phase = target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
phase.nil?.should == false
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