Commit 1f5198d1 authored by Jeremy Slater's avatar Jeremy Slater

Update test specs

Many changes are simple API changes, generally centered around the 
renaming of Library to Target.

There are also a lot of additional stubbed or test classes added to 
accommodate for the fact that real Pods installations always have one 
or more integration libraries each with one or more per spec 
libraries.
parent 26381697
...@@ -5,8 +5,15 @@ module Pod ...@@ -5,8 +5,15 @@ module Pod
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
@generator = Generator::XCConfig.new(config.sandbox, [@consumer], './Pods') target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target = Target.new(target_definition, config.sandbox)
@target.platform = :ios
library_definition = Podfile::TargetDefinition.new(@spec.name, target_definition)
@library = Target.new(library_definition, config.sandbox)
@library.spec = @spec
@library.platform = :ios
@target.libraries = [@library]
@generator = Generator::XCConfig.new(@library, [@consumer], './Pods')
end end
it "returns the sandbox" do it "returns the sandbox" do
...@@ -62,11 +69,17 @@ module Pod ...@@ -62,11 +69,17 @@ module Pod
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should =='${PODS_HEADERS_SEARCH_PATHS}' @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should =='${PODS_HEADERS_SEARCH_PATHS}'
end end
it "sets the PODS_HEADERS_SEARCH_PATHS to look for the public headers as it is overridden in the Pods project" do it "sets the PODS_HEADERS_SEARCH_PATHS to look for public and build headers for per spec library targets" do
@xcconfig.to_hash['PODS_HEADERS_SEARCH_PATHS'].should =='${PODS_PUBLIC_HEADERS_SEARCH_PATHS}' @xcconfig.to_hash['PODS_HEADERS_SEARCH_PATHS'].should =='${PODS_BUILD_HEADERS_SEARCH_PATHS} ${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
end
it "sets the PODS_HEADERS_SEARCH_PATHS to look for the public headers for the integration library target" do
xcconfig = Generator::XCConfig.new(@target, [], './Pods').generate
xcconfig.to_hash['PODS_HEADERS_SEARCH_PATHS'].should =='${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
end end
it 'adds the sandbox build headers search paths to the xcconfig, with quotes' do
expected = "\"#{config.sandbox.build_headers.search_paths.join('" "')}\"" it 'adds the library build headers search paths to the xcconfig, with quotes' do
expected = "\"#{@library.build_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['PODS_BUILD_HEADERS_SEARCH_PATHS'].should == expected @xcconfig.to_hash['PODS_BUILD_HEADERS_SEARCH_PATHS'].should == expected
end end
...@@ -76,58 +89,49 @@ module Pod ...@@ -76,58 +89,49 @@ module Pod
end end
it 'adds the COCOAPODS macro definition' do it 'adds the COCOAPODS macro definition' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == '$(inherited) COCOAPODS=1' @xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == 'COCOAPODS=1'
end
it 'adds the pod namespaced configuration items' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include("${#{@library.xcconfig_prefix}OTHER_LDFLAGS}")
end end
it "includes the xcconfig of the specifications" do it "includes the xcconfig of the specifications" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-no_compact_unwind') @xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-no_compact_unwind')
end end
it "includes the libraries for the specifications" do it "includes the libraries for the specifications" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-lxml2') @xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-lxml2')
end end
it "includes the frameworks of the specifications" do it "includes the frameworks of the specifications" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-framework QuartzCore') @xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-framework QuartzCore')
end end
it "includes the weak-frameworks of the specifications" do it "includes the weak-frameworks of the specifications" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework iAd') @xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-weak_framework iAd')
end end
it "includes the developer frameworks search paths when SenTestingKit is detected" do it "includes the developer frameworks search paths when SenTestingKit is detected" do
spec = fixture_spec('banana-lib/BananaLib.podspec') @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
consumer = spec.consumer(:ios) @spec.frameworks = ['SenTestingKit']
generator = Generator::XCConfig.new(config.sandbox, [consumer], './Pods') xcconfig = @generator.generate
spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } xcconfig.to_hash["#{@library.xcconfig_prefix}FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
spec.frameworks = ['SenTestingKit']
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end end
it "doesn't include the developer frameworks if already present" do it "doesn't include the developer frameworks if already present" do
spec = fixture_spec('banana-lib/BananaLib.podspec') consumer_1 = @spec.consumer(:ios)
consumer_1 = spec.consumer(:ios) consumer_2 = @spec.consumer(:ios)
consumer_2 = spec.consumer(:ios) generator = Generator::XCConfig.new(@library, [consumer_1, consumer_2], './Pods')
generator = Generator::XCConfig.new(config.sandbox, [consumer_1, consumer_2], './Pods') @spec.frameworks = ['SenTestingKit']
spec.frameworks = ['SenTestingKit']
xcconfig = generator.generate xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' xcconfig.to_hash["#{@library.xcconfig_prefix}FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
it 'returns the settings that the pods project needs to override' do it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
Generator::XCConfig.pods_project_settings.should.not.be.nil @xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
it 'overrides the relative path of the pods root in the Pods project' do
Generator::XCConfig.pods_project_settings['PODS_ROOT'].should == '${SRCROOT}'
end
it 'overrides the headers search path of the pods project to the build headers folder' do
expected = '${PODS_BUILD_HEADERS_SEARCH_PATHS}'
Generator::XCConfig.pods_project_settings['PODS_HEADERS_SEARCH_PATHS'].should == expected
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
config.integrate_targets = false config.integrate_targets = false
@installer = Installer.new(config.sandbox, podfile) @installer = Installer.new(config.sandbox, podfile)
@installer.send(:analyze) @installer.send(:analyze)
@specs = @installer.libraries.map(&:specs).flatten @spec = @installer.targets.first.libraries.map(&:spec).first
@installer.stubs(:installed_specs).returns(@specs) @installer.stubs(:installed_specs).returns(@specs)
@rep = Hooks::InstallerRepresentation.new(@installer) @rep = Hooks::InstallerRepresentation.new(@installer)
end end
...@@ -40,19 +40,19 @@ module Pod ...@@ -40,19 +40,19 @@ module Pod
end end
it "the hook representation of the libraries" do it "the hook representation of the libraries" do
@rep.libraries.map(&:name).should == ['Pods'] @rep.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end end
it "returns the specs by library representation" do it "returns the specs by library representation" do
specs_by_lib = @rep.specs_by_lib specs_by_lib = @rep.specs_by_lib
lib_rep = specs_by_lib.keys.first lib_rep = specs_by_lib.keys.first
lib_rep.name.should == 'Pods' lib_rep.name.should == 'Pods-JSONKit'
specs_by_lib.should == { lib_rep => @specs } specs_by_lib.should == { lib_rep => @spec }
end end
it "returns the pods representation by library representation" do it "returns the pods representation by library representation" do
pods_by_lib = @rep.pods_by_lib pods_by_lib = @rep.pods_by_lib
target_definition = @installer.libraries.first.target_definition target_definition = @installer.targets.first.libraries.first.target_definition
pods_by_lib[target_definition].map(&:name).should == ['JSONKit'] pods_by_lib[target_definition].map(&:name).should == ['JSONKit']
end end
......
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('MyApp', nil) @target_definition = Podfile::TargetDefinition.new('MyApp', nil)
@lib = Library.new(@target_definition) @lib = Target.new(@target_definition, config.sandbox)
@rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib) @rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib)
end end
......
...@@ -75,28 +75,32 @@ module Pod ...@@ -75,28 +75,32 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "generates the libraries which represent the target definitions" do it "generates the libraries which represent the target definitions" do
libs = @analyzer.analyze.libraries target = @analyzer.analyze.targets.first
libs.map(&:name).should == ['Pods'] target.libraries.map(&:name).sort.should == [
lib = libs.first 'Pods-JSONKit',
lib.support_files_root.should == config.sandbox.root 'Pods-AFNetworking',
'Pods-SVPullToRefresh',
lib.user_project_path.to_s.should.include 'SampleProject/SampleProject' 'Pods-libextobjc-EXTKeyPathCoding'
lib.client_root.to_s.should.include 'SampleProject' ].sort
lib.user_target_uuids.should == ["A346496C14F9BE9A0080D870"] target.support_files_root.should == config.sandbox.root
user_proj = Xcodeproj::Project.new(lib.user_project_path)
user_proj.objects_by_uuid[lib.user_target_uuids.first].name.should == 'SampleProject' target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
lib.user_build_configurations.should == {"Test"=>:release, "App Store"=>:release} target.client_root.to_s.should.include 'SampleProject'
lib.platform.to_s.should == 'iOS 6.0' target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"]
user_proj = Xcodeproj::Project.new(target.user_project_path)
user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject'
target.user_build_configurations.should == {"Test"=>:release, "App Store"=>:release}
target.platform.to_s.should == 'iOS 6.0'
end end
it "generates configures the library appropriately if the installation will not integrate" do it "generates the integration library appropriately if the installation will not integrate" do
config.integrate_targets = false config.integrate_targets = false
lib = @analyzer.analyze.libraries.first target = @analyzer.analyze.targets.first
lib.client_root.should == config.installation_root target.client_root.should == config.installation_root
lib.user_target_uuids.should == [] target.user_target_uuids.should == []
lib.user_build_configurations.should == {} target.user_build_configurations.should == {}
lib.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
#--------------------------------------# #--------------------------------------#
...@@ -163,8 +167,8 @@ module Pod ...@@ -163,8 +167,8 @@ module Pod
podspec.should.not.exist? podspec.should.not.exist?
end end
it "adds the specifications to the correspondent libraries in after the resolution" do xit "adds the specifications to the correspondent libraries in after the resolution" do
@analyzer.analyze.libraries.first.specs.map(&:to_s).should == [ @analyzer.analyze.targets.first.libraries.first.specs.map(&:to_s).should == [
"AFNetworking (1.0.1)", "AFNetworking (1.0.1)",
"JSONKit (1.5pre)", "JSONKit (1.5pre)",
"SVPullToRefresh (0.4)", "SVPullToRefresh (0.4)",
......
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
before do before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@library = Library.new(nil) @library = Target.new(nil, config.sandbox)
@library.file_accessors = [@file_accessor] @library.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@library], @project) @installer = Installer::FileReferencesInstaller.new(config.sandbox, [@library], @project)
...@@ -50,8 +50,8 @@ module Pod ...@@ -50,8 +50,8 @@ module Pod
it "links the build headers" do it "links the build headers" do
@installer.install! @installer.install!
headers_root = config.sandbox.build_headers.root headers_root = @library.build_headers.root
public_header = headers_root+ 'BananaLib/Banana.h' public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h' private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist public_header.should.exist
private_header.should.exist private_header.should.exist
...@@ -73,9 +73,9 @@ module Pod ...@@ -73,9 +73,9 @@ module Pod
describe "Private Helpers" do describe "Private Helpers" do
it "returns the file accessors" do it "returns the file accessors" do
library_1 = Library.new(nil) library_1 = Target.new(nil, config.sandbox)
library_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] library_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
library_2 = Library.new(nil) library_2 = Target.new(nil, config.sandbox)
library_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] library_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1, library_2], @project) installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1, library_2], @project)
roots = installer.send(:file_accessors).map { |fa| fa.path_list.root } roots = installer.send(:file_accessors).map { |fa| fa.path_list.root }
...@@ -83,7 +83,7 @@ module Pod ...@@ -83,7 +83,7 @@ module Pod
end end
it "handles libraries empty libraries without file accessors" do it "handles libraries empty libraries without file accessors" do
library_1 = Library.new(nil) library_1 = Target.new(nil, config.sandbox)
library_1.file_accessors = [] library_1.file_accessors = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1], @project) installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1], @project)
roots = installer.send(:file_accessors).should == [] roots = installer.send(:file_accessors).should == []
......
...@@ -19,13 +19,13 @@ module Pod ...@@ -19,13 +19,13 @@ module Pod
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios)) file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@project.add_file_references(file_accessor.source_files, 'BananaLib', @project.pods) @project.add_file_references(file_accessor.source_files, 'BananaLib', @project.pods)
@library = Library.new(@target_definition) @library = Target.new(@target_definition, config.sandbox)
@library.platform = Platform.new(:ios, '6.0') @library.platform = Platform.new(:ios, '6.0')
@library.support_files_root = config.sandbox.root @library.support_files_root = config.sandbox.root
@library.client_root = config.sandbox.root.dirname @library.client_root = config.sandbox.root.dirname
@library.user_project_path = config.sandbox.root + '../user_project.xcodeproj' @library.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@library.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @library.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@library.specs = [@spec] @library.spec = @spec
@library.file_accessors = [file_accessor] @library.file_accessors = [file_accessor]
@installer = TargetInstaller.new(config.sandbox, @library) @installer = TargetInstaller.new(config.sandbox, @library)
...@@ -102,15 +102,6 @@ module Pod ...@@ -102,15 +102,6 @@ module Pod
target.build_settings('AppStore')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8" target.build_settings('AppStore')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8"
end end
it "adds the settings of the xcconfig that need to be overridden to the target" do
@installer.install!
build_configuration = @project.targets.first.build_configurations
build_settings = build_configuration.first.build_settings
Generator::XCConfig.pods_project_settings.each do |key, value|
build_settings[key].should == value
end
end
it "adds the user's build configurations to the target" do it "adds the user's build configurations to the target" do
@installer.install! @installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test } @project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test }
...@@ -146,14 +137,29 @@ module Pod ...@@ -146,14 +137,29 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "creates and xcconfig file" do it "creates the xcconfig file" do
@installer.install! @installer.install!
file = config.sandbox.root + 'Pods.xcconfig' file = config.sandbox.root + @library.xcconfig_path
xcconfig = Xcodeproj::Config.new(file) xcconfig = Xcodeproj::Config.new(file)
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods' xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end end
it "creates a header for the target which contains the information about the installed Pods" do it "creates a header for the target which contains the information about the installed Pods" do
target = Target.new(@target_definition, config.sandbox)
lib_definition = Podfile::TargetDefinition.from_hash(@target_definition.to_hash, @target_definition.parent)
lib_definition.name = 'BananaLib'
library = Target.new(@target_definition, config.sandbox)
target.platform = library.platform = @library.platform
target.support_files_root = library.support_files_root = @library.support_files_root
target.client_root = library.client_root = @library.client_root
target.user_project_path = library.user_project_path = @library.user_project_path
target.user_build_configurations = library.user_build_configurations = @library.user_build_configurations
library.spec = @library.spec
library.file_accessors = @library.file_accessors
target.libraries = [library]
@installer = TargetInstaller.new(config.sandbox, target)
@installer.install! @installer.install!
file = config.sandbox.root + 'Pods-environment.h' file = config.sandbox.root + 'Pods-environment.h'
contents = file.read contents = file.read
......
...@@ -13,10 +13,11 @@ module Pod ...@@ -13,10 +13,11 @@ module Pod
before do before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path @sample_project = Xcodeproj::Project.new sample_project_path
Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@target = @sample_project.targets.first @target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
@lib = Library.new(target_definition) @lib = Target.new(target_definition, config.sandbox)
@lib.user_project_path = sample_project_path @lib.user_project_path = sample_project_path
@lib.client_root = sample_project_path.dirname @lib.client_root = sample_project_path.dirname
pods_project = Project.new() pods_project = Project.new()
...@@ -27,14 +28,14 @@ module Pod ...@@ -27,14 +28,14 @@ module Pod
end end
it 'returns the targets that need to be integrated' do it 'returns the targets that need to be integrated' do
@target_integrator.targets.map(&:name).should == %w[ SampleProject ] @target_integrator.native_targets.map(&:name).should == %w[ SampleProject ]
end end
it 'returns the targets that need to be integrated' do it 'returns the targets that need to be integrated' do
pods_library = @sample_project.frameworks_group.new_static_library('Pods') pods_library = @sample_project.frameworks_group.new_static_library('Pods')
@target.frameworks_build_phase.add_file_reference(pods_library) @target.frameworks_build_phase.add_file_reference(pods_library)
@target_integrator.stubs(:user_project).returns(@sample_project) @target_integrator.stubs(:user_project).returns(@sample_project)
@target_integrator.targets.map(&:name).should.be.empty? @target_integrator.native_targets.map(&:name).should.be.empty?
end end
it 'is robust against other types of references in the build files of the frameworks build phase' do it 'is robust against other types of references in the build files of the frameworks build phase' do
...@@ -42,7 +43,7 @@ module Pod ...@@ -42,7 +43,7 @@ module Pod
build_file.file_ref = @sample_project.new(Xcodeproj::Project::PBXVariantGroup) build_file.file_ref = @sample_project.new(Xcodeproj::Project::PBXVariantGroup)
@target_integrator.stubs(:user_project).returns(@sample_project) @target_integrator.stubs(:user_project).returns(@sample_project)
@target.frameworks_build_phase.files << build_file @target.frameworks_build_phase.files << build_file
@target_integrator.targets.map(&:name).should == %w[ SampleProject ] @target_integrator.native_targets.map(&:name).should == %w[ SampleProject ]
end end
it 'is robust against build files with missing file references' do it 'is robust against build files with missing file references' do
...@@ -50,11 +51,11 @@ module Pod ...@@ -50,11 +51,11 @@ module Pod
build_file.file_ref = nil build_file.file_ref = nil
@target_integrator.stubs(:user_project).returns(@sample_project) @target_integrator.stubs(:user_project).returns(@sample_project)
@target.frameworks_build_phase.files << build_file @target.frameworks_build_phase.files << build_file
@target_integrator.targets.map(&:name).should == %w[ SampleProject ] @target_integrator.native_targets.map(&:name).should == %w[ SampleProject ]
end end
it 'does not perform the integration if there are no targets to integrate' do it 'does not perform the integration if there are no targets to integrate' do
@target_integrator.stubs(:targets).returns([]) @target_integrator.stubs(:native_targets).returns([])
@target_integrator.expects(:add_xcconfig_base_configuration).never @target_integrator.expects(:add_xcconfig_base_configuration).never
@target_integrator.expects(:add_pods_library).never @target_integrator.expects(:add_pods_library).never
@target_integrator.expects(:add_copy_resources_script_phase).never @target_integrator.expects(:add_copy_resources_script_phase).never
...@@ -78,18 +79,18 @@ module Pod ...@@ -78,18 +79,18 @@ module Pod
end end
it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
target = @target_integrator.targets.first target = @target_integrator.native_targets.first
target.frameworks_build_phase.files.find { |f| f.file_ref.path == 'libPods.a'}.should.not == nil target.frameworks_build_phase.files.find { |f| f.file_ref.path == 'libPods.a'}.should.not == nil
end end
it 'adds a Copy Pods Resources build phase to each target' do it 'adds a Copy Pods Resources build phase to each target' do
target = @target_integrator.targets.first target = @target_integrator.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.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\"" phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\""
end end
it 'adds a Check Manifest.lock build phase to each target' do it 'adds a Check Manifest.lock build phase to each target' do
target = @target_integrator.targets.first target = @target_integrator.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 Pods Manifest.lock" }
phase.shell_script.should == <<-EOS.strip_heredoc phase.shell_script.should == <<-EOS.strip_heredoc
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
...@@ -103,7 +104,7 @@ module Pod ...@@ -103,7 +104,7 @@ module Pod
end end
it 'adds the Check Manifest.lock build phase as the first build phase' do it 'adds the Check Manifest.lock build phase as the first build phase' do
target = @target_integrator.targets.first target = @target_integrator.native_targets.first
phase = target.build_phases.find { |bp| bp.name == "Check Pods Manifest.lock" } phase = target.build_phases.find { |bp| bp.name == "Check Pods Manifest.lock" }
target.build_phases.first.should.equal? phase target.build_phases.first.should.equal? phase
end end
......
...@@ -17,12 +17,13 @@ module Pod ...@@ -17,12 +17,13 @@ module Pod
end end
end end
config.sandbox.project = Project.new() config.sandbox.project = Project.new()
@library = Library.new(@podfile.target_definitions['Pods']) Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@library = Target.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname @library.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path @library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870'] @library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@library.support_files_root = config.sandbox.root @library.support_files_root = config.sandbox.root
empty_library = Library.new(@podfile.target_definitions[:empty]) empty_library = Target.new(@podfile.target_definitions[:empty], config.sandbox)
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library]) @integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library])
end end
...@@ -148,8 +149,8 @@ module Pod ...@@ -148,8 +149,8 @@ module Pod
end end
it "skips libraries with empty target definitions" do it "skips libraries with empty target definitions" do
@integrator.libraries.map(&:name).should == ["Pods", "Pods-empty"] @integrator.targets.map(&:name).should == ["Pods", "Pods-empty"]
@integrator.send(:libraries_to_integrate).map(&:name).should == ['Pods'] @integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
end end
end end
......
...@@ -61,7 +61,7 @@ module Pod ...@@ -61,7 +61,7 @@ module Pod
@installer.stubs(:prepare_pods_project) @installer.stubs(:prepare_pods_project)
@installer.stubs(:run_pre_install_hooks) @installer.stubs(:run_pre_install_hooks)
@installer.stubs(:install_file_references) @installer.stubs(:install_file_references)
@installer.stubs(:install_targets) @installer.stubs(:install_libraries)
@installer.stubs(:write_lockfiles) @installer.stubs(:write_lockfiles)
@installer.unstub(:generate_pods_project) @installer.unstub(:generate_pods_project)
def @installer.run_post_install_hooks def @installer.run_post_install_hooks
...@@ -106,14 +106,14 @@ module Pod ...@@ -106,14 +106,14 @@ module Pod
it "stores the libraries created by the analyzer" do it "stores the libraries created by the analyzer" do
@installer.send(:analyze) @installer.send(:analyze)
@installer.libraries.map(&:name).should == ['Pods'] @installer.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end end
it "configures the analizer to use update mode if appropriate" do it "configures the analizer to use update mode if appropriate" do
@installer.update_mode = true @installer.update_mode = true
Installer::Analyzer.any_instance.expects(:update_mode=).with(true) Installer::Analyzer.any_instance.expects(:update_mode=).with(true)
@installer.send(:analyze) @installer.send(:analyze)
@installer.libraries.map(&:name).should == ['Pods'] @installer.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end end
end end
...@@ -126,12 +126,16 @@ module Pod ...@@ -126,12 +126,16 @@ module Pod
@analysis_result = Installer::Analyzer::AnalysisResult.new @analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = [] @analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new() @analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new()
@libraries = [Target.new(nil, config.sandbox)]
@installer.stubs(:analysis_result).returns(@analysis_result) @installer.stubs(:analysis_result).returns(@analysis_result)
@installer.stubs(:libraries).returns(@libraries)
end end
it "cleans the header stores" do it "cleans the header stores" do
config.sandbox.build_headers.expects(:implode!)
config.sandbox.public_headers.expects(:implode!) config.sandbox.public_headers.expects(:implode!)
@installer.libraries.each do |library|
library.build_headers.expects(:implode!)
end
@installer.send(:clean_sandbox) @installer.send(:clean_sandbox)
end end
...@@ -167,8 +171,8 @@ module Pod ...@@ -167,8 +171,8 @@ module Pod
it "correctly configures the Pod source installer" do it "correctly configures the Pod source installer" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
library = Library.new(nil) library = Target.new(nil, config.sandbox)
library.specs = [spec] library.spec = spec
library.platform = :ios library.platform = :ios
@installer.stubs(:libraries).returns([library]) @installer.stubs(:libraries).returns([library])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
...@@ -178,8 +182,8 @@ module Pod ...@@ -178,8 +182,8 @@ module Pod
it "maintains the list of the installed specs" do it "maintains the list of the installed specs" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
library = Library.new(nil) library = Target.new(nil, config.sandbox)
library.specs = [spec] library.spec = spec
@installer.stubs(:libraries).returns([library, library]) @installer.stubs(:libraries).returns([library, library])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
Installer::PodSourceInstaller.any_instance.stubs(:install!) Installer::PodSourceInstaller.any_instance.stubs(:install!)
...@@ -211,13 +215,13 @@ module Pod ...@@ -211,13 +215,13 @@ module Pod
describe "#prepare_pods_project" do describe "#prepare_pods_project" do
it "creates the Pods project" do it "creates the Pods project" do
@installer.stubs(:libraries).returns([]) @installer.stubs(:targets).returns([])
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.class.should == Pod::Project @installer.pods_project.class.should == Pod::Project
end end
it "adds the Podfile to the Pods project" do it "adds the Podfile to the Pods project" do
@installer.stubs(:libraries).returns([]) @installer.stubs(:targets).returns([])
config.podfile_path.stubs(:exist?).returns(true) config.podfile_path.stubs(:exist?).returns(true)
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
f = @installer.pods_project['Podfile'] f = @installer.pods_project['Podfile']
...@@ -225,11 +229,11 @@ module Pod ...@@ -225,11 +229,11 @@ module Pod
end end
it "sets the deployment target for the whole project" do it "sets the deployment target for the whole project" do
library_ios = Library.new(nil) library_ios = Target.new(nil, config.sandbox)
library_osx = Library.new(nil) library_osx = Target.new(nil, config.sandbox)
library_ios.platform = Platform.new(:ios, '6.0') library_ios.platform = Platform.new(:ios, '6.0')
library_osx.platform = Platform.new(:osx, '10.8') library_osx.platform = Platform.new(:osx, '10.8')
@installer.stubs(:libraries).returns([library_ios, library_osx]) @installer.stubs(:targets).returns([library_ios, library_osx])
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
build_settings = @installer.pods_project.build_configurations.map(&:build_settings) build_settings = @installer.pods_project.build_configurations.map(&:build_settings)
build_settings.should == [ build_settings.should == [
...@@ -244,6 +248,7 @@ module Pod ...@@ -244,6 +248,7 @@ module Pod
describe "#install_file_references" do describe "#install_file_references" do
it "installs the file references" do it "installs the file references" do
@installer.stubs(:libraries).returns([])
Installer::FileReferencesInstaller.any_instance.expects(:install!) Installer::FileReferencesInstaller.any_instance.expects(:install!)
@installer.send(:install_file_references) @installer.send(:install_file_references)
end end
...@@ -252,27 +257,27 @@ module Pod ...@@ -252,27 +257,27 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#install_targets" do describe "#install_libraries" do
it "install the targets of the Pod project" do it "install the targets of the Pod project" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.store_pod('BananaLib') target_definition.store_pod('BananaLib')
library = Library.new(target_definition) library = Target.new(target_definition, config.sandbox)
library.specs = [spec] library.spec = spec
@installer.stubs(:libraries).returns([library]) @installer.stubs(:libraries).returns([library])
Installer::TargetInstaller.any_instance.expects(:install!) Installer::TargetInstaller.any_instance.expects(:install!)
@installer.send(:install_targets) @installer.send(:install_libraries)
end end
it "skips empty libraries" do it "skips empty libraries" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
library = Library.new(target_definition) library = Target.new(target_definition, config.sandbox)
library.specs = [spec] library.spec = spec
@installer.stubs(:libraries).returns([library]) @installer.stubs(:libraries).returns([library])
Installer::TargetInstaller.any_instance.expects(:install!).never Installer::TargetInstaller.any_instance.expects(:install!).never
@installer.send(:install_targets) @installer.send(:install_libraries)
end end
end end
...@@ -282,7 +287,7 @@ module Pod ...@@ -282,7 +287,7 @@ module Pod
describe "#write_pod_project" do describe "#write_pod_project" do
before do before do
@installer.stubs(:libraries).returns([]) @installer.stubs(:targets).returns([])
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
end end
...@@ -340,7 +345,7 @@ module Pod ...@@ -340,7 +345,7 @@ module Pod
describe "Integrating client projects" do describe "Integrating client projects" do
it "integrates the client projects" do it "integrates the client projects" do
@installer.stubs(:libraries).returns([Library.new(nil)]) @installer.stubs(:libraries).returns([Target.new(nil, config.sandbox)])
Installer::UserProjectIntegrator.any_instance.expects(:integrate!) Installer::UserProjectIntegrator.any_instance.expects(:integrate!)
@installer.send(:integrate_user_project) @installer.send(:integrate_user_project)
end end
...@@ -353,10 +358,10 @@ module Pod ...@@ -353,10 +358,10 @@ module Pod
before do before do
@installer.send(:analyze) @installer.send(:analyze)
@specs = @installer.libraries.map(&:specs).flatten @specs = @installer.libraries.map(&:spec)
@spec = @specs.find { |spec| spec.name == 'JSONKit' } @spec = @specs.find { |spec| spec && spec.name == 'JSONKit' }
@installer.stubs(:installed_specs).returns(@specs) @installer.stubs(:installed_specs).returns(@specs)
@lib = @installer.libraries.first @lib = @installer.targets.first.libraries.first
end end
it "runs the pre install hooks" do it "runs the pre install hooks" do
...@@ -384,10 +389,10 @@ module Pod ...@@ -384,10 +389,10 @@ module Pod
end end
it "calls the hooks in the specs for each target" do it "calls the hooks in the specs for each target" do
library_ios = Library.new(nil) library_ios = Target.new(nil, config.sandbox)
library_osx = Library.new(nil) library_osx = Target.new(nil, config.sandbox)
library_ios.specs = [@spec] library_ios.spec = @spec
library_osx.specs = [@spec] library_osx.spec = @spec
library_ios.stubs(:name).returns('label') library_ios.stubs(:name).returns('label')
library_osx.stubs(:name).returns('label') library_osx.stubs(:name).returns('label')
library_ios_rep = stub() library_ios_rep = stub()
...@@ -421,7 +426,7 @@ module Pod ...@@ -421,7 +426,7 @@ module Pod
it "returns the hook representation of a library" do it "returns the hook representation of a library" do
rep = @installer.send(:library_rep, @lib) rep = @installer.send(:library_rep, @lib)
rep.send(:library).name.should == 'Pods' rep.send(:library).name.should == 'Pods-JSONKit'
end end
it "returns the hook representation of all the pods" do it "returns the hook representation of all the pods" do
...@@ -431,12 +436,12 @@ module Pod ...@@ -431,12 +436,12 @@ module Pod
it "returns the hook representation of all the target installers" do it "returns the hook representation of all the target installers" do
reps = @installer.send(:library_reps) reps = @installer.send(:library_reps)
reps.map(&:name).should == ['Pods'] reps.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end end
it "returns the libraries which use a given Pod" do it "returns the libraries which use a given Pod" do
libs = @installer.send(:libraries_using_spec, @spec) libs = @installer.send(:libraries_using_spec, @spec)
libs.map(&:name).should == ['Pods'] libs.map(&:name).should == ['Pods-JSONKit']
end end
end end
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Pod::Library do describe Pod::Target do
describe "In general" do describe "In general" do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@lib = Library.new(@target_definition) @lib = Target.new(@target_definition, config.sandbox)
end end
it "returns the target_definition that generated it" do it "returns the target_definition that generated it" do
...@@ -31,7 +31,7 @@ module Pod ...@@ -31,7 +31,7 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@lib = Library.new(@target_definition) @lib = Target.new(@target_definition, config.sandbox)
@lib.support_files_root = config.sandbox.root @lib.support_files_root = config.sandbox.root
@lib.client_root = config.sandbox.root.dirname @lib.client_root = config.sandbox.root.dirname
end end
......
...@@ -27,10 +27,6 @@ module Pod ...@@ -27,10 +27,6 @@ module Pod
@sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers' @sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers'
end end
it "returns the build headers store" do
@sandbox.build_headers.root.should == temporary_directory + 'Sandbox/BuildHeaders'
end
it "deletes the entire root directory on implode" do it "deletes the entire root directory on implode" do
@sandbox.implode @sandbox.implode
File.directory?(temporary_directory + 'Sandbox').should.be.false File.directory?(temporary_directory + 'Sandbox').should.be.false
......
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