Commit ae4e411e authored by Jeremy Slater's avatar Jeremy Slater

Update tests

parent 2719a381
......@@ -2,6 +2,97 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Generator::AggregateXCConfig do
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target = AggregateTarget.new(target_definition, config.sandbox)
@target.client_root = config.sandbox.root.dirname
@target.stubs(:platform).returns(:ios)
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer])
@target.pod_targets = [@pod_target]
@generator = Generator::AggregateXCConfig.new(@target)
end
it "returns the sandbox" do
@generator.sandbox.class.should == Sandbox
end
it "returns the path of the pods root relative to the user project" do
@generator.target.relative_pods_root.should == '${SRCROOT}/Pods'
end
#-----------------------------------------------------------------------#
before do
@podfile = Podfile.new
@target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate
end
it "generates the xcconfig" do
@xcconfig.class.should == Xcodeproj::Config
end
it "sets to always search the user paths" do
@xcconfig.to_hash['ALWAYS_SEARCH_USER_PATHS'].should == 'YES'
end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
it "sets the PODS_ROOT build variable" do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do
expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected
end
it 'adds the COCOAPODS macro definition' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include 'COCOAPODS=1'
end
it 'inherits the parent GCC_PREPROCESSOR_DEFINITIONS value' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)'
end
it 'adds the pod namespaced configuration items' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include("${#{@pod_target.xcconfig_prefix}OTHER_LDFLAGS}")
end
#-----------------------------------------------------------------------#
before do
@path = temporary_directory + 'sample.xcconfig'
@generator.save_as(@path)
end
it "saves the xcconfig" do
generated = Xcodeproj::Config.new(@path)
generated.class.should == Xcodeproj::Config
end
it "includes the namespaced public pod xcconfig file" do
generated = Xcodeproj::Config.new(@path)
generated.includes.should.include("#{@pod_target.label}")
end
end
end
......@@ -2,6 +2,84 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Generator::PrivatePodXCConfig do
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
@generator = Generator::PrivatePodXCConfig.new(@pod_target)
end
it "returns the sandbox" do
@generator.sandbox.class.should == Sandbox
end
#-----------------------------------------------------------------------#
before do
@podfile = Podfile.new
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate
end
it "generates the xcconfig" do
@xcconfig.class.should == Xcodeproj::Config
end
it "sets to always search the user paths" do
@xcconfig.to_hash['ALWAYS_SEARCH_USER_PATHS'].should == 'YES'
end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
it "sets the PODS_ROOT build variable" do
@xcconfig.to_hash['PODS_ROOT'].should.not == nil
end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
private_headers = "\"#{@pod_target.build_headers.search_paths.join('" "')}\""
public_headers = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers
end
it 'adds the COCOAPODS macro definition' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include 'COCOAPODS=1'
end
it 'adds the pod namespaced configuration items' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include("${#{@pod_target.xcconfig_prefix}OTHER_LDFLAGS}")
end
#-----------------------------------------------------------------------#
it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
#-----------------------------------------------------------------------#
it "saves the xcconfig" do
path = temporary_directory + 'sample.xcconfig'
@generator.save_as(path)
generated = Xcodeproj::Config.new(path)
generated.class.should == Xcodeproj::Config
end
end
end
......@@ -2,6 +2,84 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Generator::PublicPodXCConfig do
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
@generator = Generator::PublicPodXCConfig.new(@pod_target)
end
it "returns the sandbox" do
@generator.sandbox.class.should == Sandbox
end
#-----------------------------------------------------------------------#
before do
@podfile = Podfile.new
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2']
@xcconfig = @generator.generate
end
it "generates the xcconfig" do
@xcconfig.class.should == Xcodeproj::Config
end
it "includes the xcconfig of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-no_compact_unwind')
end
it "includes the libraries for the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-lxml2')
end
it "includes the frameworks of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-framework QuartzCore')
end
it "includes the weak-frameworks of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-weak_framework iAd')
end
it "includes the developer frameworks search paths when SenTestingKit is detected" do
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end
it "doesn't include the developer frameworks if already present" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([@spec, spec], @target_definition, config.sandbox)
pod_target.stubs(:platform).returns(:ios)
generator = Generator::PublicPodXCConfig.new(pod_target)
@spec.frameworks = ['SenTestingKit']
spec.frameworks = ['SenTestingKit']
xcconfig = generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end
#-----------------------------------------------------------------------#
before do
@path = temporary_directory + 'sample.xcconfig'
@generator.save_as(@path)
end
it "saves the xcconfig" do
generated = Xcodeproj::Config.new(@path)
generated.class.should == Xcodeproj::Config
end
it "writes the xcconfig with a prefix computed from the target definition and root spec" do
generated = Xcodeproj::Config.new(@path)
generated.to_hash.each { |k, v| k.should.start_with(@pod_target.xcconfig_prefix) }
end
end
end
......@@ -2,146 +2,6 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::XCConfig do
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios)
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
it "returns the sandbox" do
@generator.sandbox.class.should == Sandbox
end
it "returns the pods" do
names = @generator.spec_consumers.should == [@consumer]
end
it "returns the path of the pods root relative to the user project" do
@generator.relative_pods_root.should == './Pods'
end
#-----------------------------------------------------------------------#
before do
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2']
@xcconfig = @generator.generate
end
it "generates the xcconfig" do
@xcconfig.class.should == Xcodeproj::Config
end
it "sets to always search the user paths" do
@xcconfig.to_hash['ALWAYS_SEARCH_USER_PATHS'].should == 'YES'
end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)' do
@generator.set_arc_compatibility_flag = true
@consumer.stubs(:requires_arc).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
it "sets the PODS_ROOT build variable" do
@xcconfig.to_hash['PODS_ROOT'].should.not == nil
end
it "redirects the HEADERS_SEARCH_PATHS to the pod variable" do
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should =='${PODS_HEADERS_SEARCH_PATHS}'
end
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_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
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
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do
expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['PODS_PUBLIC_HEADERS_SEARCH_PATHS'].should == expected
end
it 'adds the COCOAPODS macro definition' do
@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
it "includes the xcconfig of the specifications" do
@xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-no_compact_unwind')
end
it "includes the libraries for the specifications" do
@xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-lxml2')
end
it "includes the frameworks of the specifications" do
@xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-framework QuartzCore')
end
it "includes the weak-frameworks of the specifications" do
@xcconfig.to_hash["#{@library.xcconfig_prefix}OTHER_LDFLAGS"].should.include('-weak_framework iAd')
end
it "includes the developer frameworks search paths when SenTestingKit is detected" do
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate
xcconfig.to_hash["#{@library.xcconfig_prefix}FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end
it "doesn't include the developer frameworks if already present" do
consumer_1 = @spec.consumer(:ios)
consumer_2 = @spec.consumer(:ios)
generator = Generator::XCConfig.new(@library, [consumer_1, consumer_2], './Pods')
@spec.frameworks = ['SenTestingKit']
xcconfig = generator.generate
xcconfig.to_hash["#{@library.xcconfig_prefix}FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
end
#-----------------------------------------------------------------------#
it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
#-----------------------------------------------------------------------#
it "saves the xcconfig" do
path = temporary_directory + 'sample.xcconfig'
@generator.save_as(path)
generated = Xcodeproj::Config.new(path)
generated.class.should == Xcodeproj::Config
end
end
end
......@@ -16,7 +16,7 @@ module Pod
config.integrate_targets = false
@installer = Installer.new(config.sandbox, podfile)
@installer.send(:analyze)
@spec = @installer.targets.first.libraries.map(&:spec).first
@specs = @installer.targets.first.pod_targets.first.specs
@installer.stubs(:installed_specs).returns(@specs)
@rep = Hooks::InstallerRepresentation.new(@installer)
end
......@@ -40,19 +40,19 @@ module Pod
end
it "the hook representation of the libraries" do
@rep.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
@rep.libraries.map(&:name).sort.should == ['Pods-JSONKit'].sort
end
it "returns the specs by library representation" do
specs_by_lib = @rep.specs_by_lib
lib_rep = specs_by_lib.keys.first
lib_rep.name.should == 'Pods-JSONKit'
specs_by_lib.should == { lib_rep => @spec }
specs_by_lib.should == { lib_rep => @specs }
end
it "returns the pods representation by library representation" do
pods_by_lib = @rep.pods_by_lib
target_definition = @installer.targets.first.libraries.first.target_definition
target_definition = @installer.targets.first.pod_targets.first.target_definition
pods_by_lib[target_definition].map(&:name).should == ['JSONKit']
end
......
......@@ -5,7 +5,9 @@ module Pod
before do
@target_definition = Podfile::TargetDefinition.new('MyApp', nil)
@lib = Target.new(@target_definition, config.sandbox)
@spec = Spec.new
@spec.name = 'RestKit'
@lib = PodTarget.new([@spec], @target_definition, config.sandbox)
@rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib)
end
......@@ -14,7 +16,7 @@ module Pod
describe "Public Hooks API" do
it "returns the name" do
@rep.name.should == 'Pods-MyApp'
@rep.name.should == 'Pods-MyApp-RestKit'
end
it "returns the dependencies" do
......@@ -27,13 +29,7 @@ module Pod
end
it "returns the path of the prefix header" do
@lib.support_files_root = temporary_directory
@rep.prefix_header_path.should == temporary_directory + 'Pods-MyApp-prefix.pch'
end
it "returns the path of the copy resources script" do
@lib.support_files_root = temporary_directory
@rep.copy_resources_script_path.should == temporary_directory + 'Pods-MyApp-resources.sh'
@rep.prefix_header_path.should == temporary_directory + 'Pods/Pods-MyApp-RestKit-prefix.pch'
end
it "returns the pods project" do
......
......@@ -76,11 +76,11 @@ module Pod
it "generates the libraries which represent the target definitions" do
target = @analyzer.analyze.targets.first
target.libraries.map(&:name).sort.should == [
target.pod_targets.map(&:name).sort.should == [
'Pods-JSONKit',
'Pods-AFNetworking',
'Pods-SVPullToRefresh',
'Pods-libextobjc-EXTKeyPathCoding'
'Pods-libextobjc'
].sort
target.support_files_root.should == config.sandbox.root
......@@ -167,8 +167,8 @@ module Pod
podspec.should.not.exist?
end
xit "adds the specifications to the correspondent libraries in after the resolution" do
@analyzer.analyze.targets.first.libraries.first.specs.map(&:to_s).should == [
it "adds the specifications to the correspondent libraries" do
@analyzer.analyze.targets.first.pod_targets.map(&:specs).flatten.map(&:to_s).should == [
"AFNetworking (1.0.1)",
"JSONKit (1.5pre)",
"SVPullToRefresh (0.4)",
......
......@@ -5,10 +5,10 @@ module Pod
before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@library = Target.new(nil, config.sandbox)
@library.file_accessors = [@file_accessor]
@pod_target = PodTarget.new([], nil, config.sandbox)
@pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@library], @project)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project)
end
#-------------------------------------------------------------------------#
......@@ -50,7 +50,7 @@ module Pod
it "links the build headers" do
@installer.install!
headers_root = @library.build_headers.root
headers_root = @pod_target.build_headers.root
public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
......@@ -73,19 +73,19 @@ module Pod
describe "Private Helpers" do
it "returns the file accessors" do
library_1 = Target.new(nil, config.sandbox)
library_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
library_2 = Target.new(nil, config.sandbox)
library_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1, library_2], @project)
pod_target_1 = PodTarget.new([], nil, config.sandbox)
pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
pod_target_2 = PodTarget.new([], nil, config.sandbox)
pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1, pod_target_2], @project)
roots = installer.send(:file_accessors).map { |fa| fa.path_list.root }
roots.should == [fixture('banana-lib'), fixture('banana-lib')]
end
it "handles libraries empty libraries without file accessors" do
library_1 = Target.new(nil, config.sandbox)
library_1.file_accessors = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1], @project)
pod_target_1 = PodTarget.new([], nil, config.sandbox)
pod_target_1.file_accessors = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1], @project)
roots = installer.send(:file_accessors).should == []
end
......
......@@ -2,8 +2,173 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Installer::AggregateTargetInstaller do
describe "In General" do
before do
@podfile = Podfile.new do
platform :ios
xcodeproj 'dummy'
end
@target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path)
config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib'))
@spec = fixture_spec('banana-lib/BananaLib.podspec')
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@project.add_file_references(file_accessor.source_files, 'BananaLib', @project.pods)
@target = AggregateTarget.new(@target_definition, config.sandbox)
@target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@target.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@target.client_root = config.sandbox.root.dirname
@target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.user_build_configurations = @target.user_build_configurations
@pod_target.file_accessors = [file_accessor]
@target.pod_targets = [@pod_target]
@installer = Installer::AggregateTargetInstaller.new(config.sandbox, @target)
@spec.prefix_header_contents = '#import "BlocksKit.h"'
end
it "adds file references for the support files of the target" do
@installer.install!
group = @project.support_files_group['Pods']
group.children.map(&:display_name).sort.should == [
"Pods-acknowledgements.markdown",
"Pods-acknowledgements.plist",
"Pods-dummy.m",
"Pods-environment.h",
"Pods-resources.sh",
"Pods.xcconfig"
]
end
#--------------------------------------#
it 'adds the target for the static library to the project' do
@installer.install!
@project.targets.count.should == 1
@project.targets.first.name.should == @target_definition.label
end
it "adds the user build configurations to the target" do
@installer.install!
target = @project.targets.first
target.build_settings('Test')["VALIDATE_PRODUCT"].should == nil
target.build_settings('AppStore')["VALIDATE_PRODUCT"].should == "YES"
end
it "sets ARCHS to 'armv6 armv7' for both configurations if the deployment target is less than 4.3 for iOS targets" do
@target.stubs(:platform).returns(Platform.new(:ios, '4.0'))
@installer.install!
target = @project.targets.first
target.build_settings('Debug')["ARCHS"].should == "armv6 armv7"
target.build_settings('Release')["ARCHS"].should == "armv6 armv7"
end
it "uses standard ARCHs if deployment target is 4.3 or above" do
@installer.install!
target = @project.targets.first
target.build_settings('Debug')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
target.build_settings('AppStore')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
end
it "sets VALIDATE_PRODUCT to YES for the Release configuration for iOS targets" do
@installer.install!
target = @project.targets.first
target.build_settings('Release')["VALIDATE_PRODUCT"].should == "YES"
end
it "sets the platform and the deployment target for iOS targets" do
@installer.install!
target = @project.targets.first
target.platform_name.should == :ios
target.deployment_target.should == "6.0"
target.build_settings('Debug')["IPHONEOS_DEPLOYMENT_TARGET"].should == "6.0"
target.build_settings('AppStore')["IPHONEOS_DEPLOYMENT_TARGET"].should == "6.0"
end
it "sets the platform and the deployment target for OS X targets" do
@target.stubs(:platform).returns(Platform.new(:osx, '10.8'))
@installer.install!
target = @project.targets.first
target.platform_name.should == :osx
target.deployment_target.should == "10.8"
target.build_settings('Debug')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8"
target.build_settings('AppStore')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8"
end
it "adds the user's build configurations to the target" do
@installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test }
end
it "it creates different hash instances for the build settings of various build configurations" do
@installer.install!
build_settings = @project.targets.first.build_configurations.map(&:build_settings)
build_settings.map(&:object_id).uniq.count.should == 4
end
it "does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default" do
@installer.install!
@installer.library.target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end
end
#--------------------------------------#
it "creates the xcconfig file" do
@installer.install!
file = config.sandbox.root + @target.xcconfig_path
xcconfig = Xcodeproj::Config.new(file)
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end
it "creates a header for the target which contains the information about the installed Pods" do
@installer.install!
file = config.sandbox.root + 'Pods-environment.h'
contents = file.read
contents.should.include?('#define COCOAPODS_POD_AVAILABLE_BananaLib')
contents.should.include?('#define COCOAPODS_VERSION_MAJOR_BananaLib 1')
contents.should.include?('#define COCOAPODS_VERSION_MINOR_BananaLib 0')
contents.should.include?('#define COCOAPODS_VERSION_PATCH_BananaLib 0')
end
it "creates a bridge support file" do
Podfile.any_instance.stubs(:generate_bridge_support? => true)
Generator::BridgeSupport.any_instance.expects(:save_as).once
@installer.install!
end
it "creates a create copy resources script" do
@installer.install!
script = config.sandbox.root + 'Pods-resources.sh'
script.read.should.include?('logo-sidebar.png')
end
it "creates the acknowledgements files " do
@installer.install!
markdown = config.sandbox.root + 'Pods-acknowledgements.markdown'
markdown.read.should.include?('Permission is hereby granted')
plist = config.sandbox.root + 'Pods-acknowledgements.plist'
plist.read.should.include?('Permission is hereby granted')
end
it "creates a dummy source to ensure the creation of a single base library" do
@installer.install!
build_files = @installer.library.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.name == 'Pods-dummy.m' }
build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m'
dummy = config.sandbox.root + 'Pods-dummy.m'
dummy.read.should.include?('@interface PodsDummy_Pods')
end
end
end
end
......@@ -17,13 +17,10 @@ module Pod
@target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
@lib = Target.new(target_definition, config.sandbox)
@lib = AggregateTarget.new(target_definition, config.sandbox)
@lib.user_project_path = sample_project_path
@lib.client_root = sample_project_path.dirname
pods_project = Project.new()
@lib.target = pods_project.new_target(:static_library, target_definition.label, :ios)
@lib.user_target_uuids = [@target.uuid]
@lib.support_files_root = config.sandbox.root
@target_integrator = TargetIntegrator.new(@lib)
end
......
......@@ -18,12 +18,11 @@ module Pod
end
config.sandbox.project = Project.new()
Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@library = Target.new(@podfile.target_definitions['Pods'], config.sandbox)
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@library.support_files_root = config.sandbox.root
empty_library = Target.new(@podfile.target_definitions[:empty], config.sandbox)
empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox)
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library])
end
......
This diff is collapsed.
require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Pod::Target do
describe Pod::AggregateTarget do
describe "In general" do
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@lib = Target.new(@target_definition, config.sandbox)
@lib = AggregateTarget.new(@target_definition, config.sandbox)
end
it "returns the target_definition that generated it" do
......@@ -31,8 +31,7 @@ module Pod
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@lib = Target.new(@target_definition, config.sandbox)
@lib.support_files_root = config.sandbox.root
@lib = AggregateTarget.new(@target_definition, config.sandbox)
@lib.client_root = config.sandbox.root.dirname
end
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe AggregateTarget do
describe "In general" do
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox)
end
end
it "returns the target_definition that generated it" do
@target.target_definition.should == @target_definition
end
end
it "returns the label of the target definition" do
@target.label.should == 'Pods'
end
it "returns its name" do
@target.name.should == 'Pods'
end
it "returns the name of its product" do
@target.product_name.should == 'libPods.a'
end
end
describe "Support files" do
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox)
@target.client_root = config.sandbox.root.dirname
end
it "returns the absolute path of the xcconfig file" do
@target.xcconfig_path.to_s.should.include?('Pods/Pods.xcconfig')
end
it "returns the absolute path of the resources script" do
@target.copy_resources_script_path.to_s.should.include?('Pods/Pods-resources.sh')
end
it "returns the absolute path of the target header file" do
@target.target_environment_header_path.to_s.should.include?('Pods/Pods-environment.h')
end
it "returns the absolute path of the prefix header file" do
@target.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch')
end
it "returns the absolute path of the bridge support file" do
@target.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport')
end
it "returns the absolute path of the acknowledgements files without extension" do
@target.acknowledgements_basepath.to_s.should.include?('Pods/Pods-acknowledgements')
end
#--------------------------------------#
it "returns the path of the resources script relative to the user project" do
@target.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh'
end
it "returns the path of the xcconfig file relative to the user project" do
@target.xcconfig_relative_path.should == 'Pods/Pods.xcconfig'
end
end
describe "Pod targets" do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new('Pods', nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox)
@target = AggregateTarget.new(target_definition, config.sandbox)
@target.stubs(:platform).returns(:ios)
@target.pod_targets = [pod_target]
end
it "returns the spec consumers for the pod targets" do
@target.spec_consumers.should.not == nil
end
end
end
end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe PodTarget do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
end
describe "In general" do
it "returns the target_definition that generated it" do
@pod_target.target_definition.should == @target_definition
end
xit "returns the label for the target" do
it "returns its name" do
@pod_target.name.should == 'Pods-BananaLib'
end
it "returns the name of its product" do
@pod_target.product_name.should == 'libPods-BananaLib.a'
end
it "returns the spec consumers for the pod targets" do
@pod_target.spec_consumers.should.not == nil
end
end
xit "returns the consumer of the spec" do
describe "Support files" do
it "returns the absolute path of the xcconfig file" do
@pod_target.xcconfig_path.to_s.should.include 'Pods/Pods-BananaLib.xcconfig'
end
it "returns the absolute path of the target header file" do
@pod_target.target_environment_header_path.to_s.should.include 'Pods/Pods-environment.h'
end
it "returns the absolute path of the prefix header file" do
@pod_target.prefix_header_path.to_s.should.include 'Pods/Pods-BananaLib-prefix.pch'
end
it "returns the absolute path of the bridge support file" do
@pod_target.bridge_support_path.to_s.should.include 'Pods/Pods-BananaLib.bridgesupport'
end
it "returns the absolute path of the public and private xcconfig files" do
@pod_target.xcconfig_path.to_s.should.include 'Pods/Pods-BananaLib.xcconfig'
@pod_target.xcconfig_private_path.to_s.should.include 'Pods/Pods-BananaLib-Private.xcconfig'
end
end
end
end
require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Target do
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