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
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@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
it "returns the sandbox" do
......@@ -62,11 +69,17 @@ module Pod
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should =='${PODS_HEADERS_SEARCH_PATHS}'
end
it "sets the PODS_HEADERS_SEARCH_PATHS to look for the public headers as it is overridden in the Pods project" do
@xcconfig.to_hash['PODS_HEADERS_SEARCH_PATHS'].should =='${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
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 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
end
......@@ -76,58 +89,49 @@ module Pod
end
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
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
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
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
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
it "includes the developer frameworks search paths when SenTestingKit is detected" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
consumer = spec.consumer(:ios)
generator = Generator::XCConfig.new(config.sandbox, [consumer], './Pods')
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"'
@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
spec = fixture_spec('banana-lib/BananaLib.podspec')
consumer_1 = spec.consumer(:ios)
consumer_2 = spec.consumer(:ios)
generator = Generator::XCConfig.new(config.sandbox, [consumer_1, consumer_2], './Pods')
spec.frameworks = ['SenTestingKit']
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['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
#-----------------------------------------------------------------------#
it 'returns the settings that the pods project needs to override' do
Generator::XCConfig.pods_project_settings.should.not.be.nil
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
it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
#-----------------------------------------------------------------------#
......
......@@ -16,7 +16,7 @@ module Pod
config.integrate_targets = false
@installer = Installer.new(config.sandbox, podfile)
@installer.send(:analyze)
@specs = @installer.libraries.map(&:specs).flatten
@spec = @installer.targets.first.libraries.map(&:spec).first
@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).should == ['Pods']
@rep.libraries.map(&:name).sort.should == ['Pods', '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'
specs_by_lib.should == { lib_rep => @specs }
lib_rep.name.should == 'Pods-JSONKit'
specs_by_lib.should == { lib_rep => @spec }
end
it "returns the pods representation by library representation" do
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']
end
......
......@@ -5,7 +5,7 @@ module Pod
before do
@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)
end
......
......@@ -75,28 +75,32 @@ module Pod
#--------------------------------------#
it "generates the libraries which represent the target definitions" do
libs = @analyzer.analyze.libraries
libs.map(&:name).should == ['Pods']
lib = libs.first
lib.support_files_root.should == config.sandbox.root
lib.user_project_path.to_s.should.include 'SampleProject/SampleProject'
lib.client_root.to_s.should.include 'SampleProject'
lib.user_target_uuids.should == ["A346496C14F9BE9A0080D870"]
user_proj = Xcodeproj::Project.new(lib.user_project_path)
user_proj.objects_by_uuid[lib.user_target_uuids.first].name.should == 'SampleProject'
lib.user_build_configurations.should == {"Test"=>:release, "App Store"=>:release}
lib.platform.to_s.should == 'iOS 6.0'
target = @analyzer.analyze.targets.first
target.libraries.map(&:name).sort.should == [
'Pods-JSONKit',
'Pods-AFNetworking',
'Pods-SVPullToRefresh',
'Pods-libextobjc-EXTKeyPathCoding'
].sort
target.support_files_root.should == config.sandbox.root
target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject'
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
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
lib = @analyzer.analyze.libraries.first
target = @analyzer.analyze.targets.first
lib.client_root.should == config.installation_root
lib.user_target_uuids.should == []
lib.user_build_configurations.should == {}
lib.platform.to_s.should == 'iOS 6.0'
target.client_root.should == config.installation_root
target.user_target_uuids.should == []
target.user_build_configurations.should == {}
target.platform.to_s.should == 'iOS 6.0'
end
#--------------------------------------#
......@@ -163,8 +167,8 @@ module Pod
podspec.should.not.exist?
end
it "adds the specifications to the correspondent libraries in after the resolution" do
@analyzer.analyze.libraries.first.specs.map(&:to_s).should == [
xit "adds the specifications to the correspondent libraries in after the resolution" do
@analyzer.analyze.targets.first.libraries.first.specs.map(&:to_s).should == [
"AFNetworking (1.0.1)",
"JSONKit (1.5pre)",
"SVPullToRefresh (0.4)",
......
......@@ -5,7 +5,7 @@ module Pod
before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@library = Library.new(nil)
@library = Target.new(nil, config.sandbox)
@library.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@library], @project)
......@@ -50,8 +50,8 @@ module Pod
it "links the build headers" do
@installer.install!
headers_root = config.sandbox.build_headers.root
public_header = headers_root+ 'BananaLib/Banana.h'
headers_root = @library.build_headers.root
public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
private_header.should.exist
......@@ -73,9 +73,9 @@ module Pod
describe "Private Helpers" 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_2 = Library.new(nil)
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)
roots = installer.send(:file_accessors).map { |fa| fa.path_list.root }
......@@ -83,7 +83,7 @@ module Pod
end
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 = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [library_1], @project)
roots = installer.send(:file_accessors).should == []
......
......@@ -19,13 +19,13 @@ module Pod
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@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.support_files_root = config.sandbox.root
@library.client_root = config.sandbox.root.dirname
@library.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@library.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@library.specs = [@spec]
@library.spec = @spec
@library.file_accessors = [file_accessor]
@installer = TargetInstaller.new(config.sandbox, @library)
......@@ -102,15 +102,6 @@ module Pod
target.build_settings('AppStore')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8"
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
@installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test }
......@@ -146,14 +137,29 @@ module Pod
#--------------------------------------#
it "creates and xcconfig file" do
it "creates the xcconfig file" do
@installer.install!
file = config.sandbox.root + 'Pods.xcconfig'
file = config.sandbox.root + @library.xcconfig_path
xcconfig = Xcodeproj::Config.new(file)
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
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!
file = config.sandbox.root + 'Pods-environment.h'
contents = file.read
......
......@@ -13,10 +13,11 @@ module Pod
before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path
Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil)
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.client_root = sample_project_path.dirname
pods_project = Project.new()
......@@ -27,14 +28,14 @@ module Pod
end
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
it 'returns the targets that need to be integrated' do
pods_library = @sample_project.frameworks_group.new_static_library('Pods')
@target.frameworks_build_phase.add_file_reference(pods_library)
@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
it 'is robust against other types of references in the build files of the frameworks build phase' do
......@@ -42,7 +43,7 @@ module Pod
build_file.file_ref = @sample_project.new(Xcodeproj::Project::PBXVariantGroup)
@target_integrator.stubs(:user_project).returns(@sample_project)
@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
it 'is robust against build files with missing file references' do
......@@ -50,11 +51,11 @@ module Pod
build_file.file_ref = nil
@target_integrator.stubs(:user_project).returns(@sample_project)
@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
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_pods_library).never
@target_integrator.expects(:add_copy_resources_script_phase).never
......@@ -78,18 +79,18 @@ module Pod
end
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
end
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.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\""
end
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.shell_script.should == <<-EOS.strip_heredoc
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
......@@ -103,7 +104,7 @@ module Pod
end
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" }
target.build_phases.first.should.equal? phase
end
......
......@@ -17,12 +17,13 @@ module Pod
end
end
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.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@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])
end
......@@ -148,8 +149,8 @@ module Pod
end
it "skips libraries with empty target definitions" do
@integrator.libraries.map(&:name).should == ["Pods", "Pods-empty"]
@integrator.send(:libraries_to_integrate).map(&:name).should == ['Pods']
@integrator.targets.map(&:name).should == ["Pods", "Pods-empty"]
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
end
end
......
......@@ -61,7 +61,7 @@ module Pod
@installer.stubs(:prepare_pods_project)
@installer.stubs(:run_pre_install_hooks)
@installer.stubs(:install_file_references)
@installer.stubs(:install_targets)
@installer.stubs(:install_libraries)
@installer.stubs(:write_lockfiles)
@installer.unstub(:generate_pods_project)
def @installer.run_post_install_hooks
......@@ -106,14 +106,14 @@ module Pod
it "stores the libraries created by the analyzer" do
@installer.send(:analyze)
@installer.libraries.map(&:name).should == ['Pods']
@installer.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end
it "configures the analizer to use update mode if appropriate" do
@installer.update_mode = true
Installer::Analyzer.any_instance.expects(:update_mode=).with(true)
@installer.send(:analyze)
@installer.libraries.map(&:name).should == ['Pods']
@installer.libraries.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end
end
......@@ -126,12 +126,16 @@ module Pod
@analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new()
@libraries = [Target.new(nil, config.sandbox)]
@installer.stubs(:analysis_result).returns(@analysis_result)
@installer.stubs(:libraries).returns(@libraries)
end
it "cleans the header stores" do
config.sandbox.build_headers.expects(:implode!)
config.sandbox.public_headers.expects(:implode!)
@installer.libraries.each do |library|
library.build_headers.expects(:implode!)
end
@installer.send(:clean_sandbox)
end
......@@ -167,8 +171,8 @@ module Pod
it "correctly configures the Pod source installer" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
library = Library.new(nil)
library.specs = [spec]
library = Target.new(nil, config.sandbox)
library.spec = spec
library.platform = :ios
@installer.stubs(:libraries).returns([library])
@installer.instance_variable_set(:@installed_specs, [])
......@@ -178,8 +182,8 @@ module Pod
it "maintains the list of the installed specs" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
library = Library.new(nil)
library.specs = [spec]
library = Target.new(nil, config.sandbox)
library.spec = spec
@installer.stubs(:libraries).returns([library, library])
@installer.instance_variable_set(:@installed_specs, [])
Installer::PodSourceInstaller.any_instance.stubs(:install!)
......@@ -211,13 +215,13 @@ module Pod
describe "#prepare_pods_project" do
it "creates the Pods project" do
@installer.stubs(:libraries).returns([])
@installer.stubs(:targets).returns([])
@installer.send(:prepare_pods_project)
@installer.pods_project.class.should == Pod::Project
end
it "adds the Podfile to the Pods project" do
@installer.stubs(:libraries).returns([])
@installer.stubs(:targets).returns([])
config.podfile_path.stubs(:exist?).returns(true)
@installer.send(:prepare_pods_project)
f = @installer.pods_project['Podfile']
......@@ -225,11 +229,11 @@ module Pod
end
it "sets the deployment target for the whole project" do
library_ios = Library.new(nil)
library_osx = Library.new(nil)
library_ios = Target.new(nil, config.sandbox)
library_osx = Target.new(nil, config.sandbox)
library_ios.platform = Platform.new(:ios, '6.0')
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)
build_settings = @installer.pods_project.build_configurations.map(&:build_settings)
build_settings.should == [
......@@ -244,6 +248,7 @@ module Pod
describe "#install_file_references" do
it "installs the file references" do
@installer.stubs(:libraries).returns([])
Installer::FileReferencesInstaller.any_instance.expects(:install!)
@installer.send(:install_file_references)
end
......@@ -252,27 +257,27 @@ module Pod
#--------------------------------------#
describe "#install_targets" do
describe "#install_libraries" do
it "install the targets of the Pod project" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.store_pod('BananaLib')
library = Library.new(target_definition)
library.specs = [spec]
library = Target.new(target_definition, config.sandbox)
library.spec = spec
@installer.stubs(:libraries).returns([library])
Installer::TargetInstaller.any_instance.expects(:install!)
@installer.send(:install_targets)
@installer.send(:install_libraries)
end
it "skips empty libraries" do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil)
library = Library.new(target_definition)
library.specs = [spec]
library = Target.new(target_definition, config.sandbox)
library.spec = spec
@installer.stubs(:libraries).returns([library])
Installer::TargetInstaller.any_instance.expects(:install!).never
@installer.send(:install_targets)
@installer.send(:install_libraries)
end
end
......@@ -282,7 +287,7 @@ module Pod
describe "#write_pod_project" do
before do
@installer.stubs(:libraries).returns([])
@installer.stubs(:targets).returns([])
@installer.send(:prepare_pods_project)
end
......@@ -340,7 +345,7 @@ module Pod
describe "Integrating 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.send(:integrate_user_project)
end
......@@ -353,10 +358,10 @@ module Pod
before do
@installer.send(:analyze)
@specs = @installer.libraries.map(&:specs).flatten
@spec = @specs.find { |spec| spec.name == 'JSONKit' }
@specs = @installer.libraries.map(&:spec)
@spec = @specs.find { |spec| spec && spec.name == 'JSONKit' }
@installer.stubs(:installed_specs).returns(@specs)
@lib = @installer.libraries.first
@lib = @installer.targets.first.libraries.first
end
it "runs the pre install hooks" do
......@@ -384,10 +389,10 @@ module Pod
end
it "calls the hooks in the specs for each target" do
library_ios = Library.new(nil)
library_osx = Library.new(nil)
library_ios.specs = [@spec]
library_osx.specs = [@spec]
library_ios = Target.new(nil, config.sandbox)
library_osx = Target.new(nil, config.sandbox)
library_ios.spec = @spec
library_osx.spec = @spec
library_ios.stubs(:name).returns('label')
library_osx.stubs(:name).returns('label')
library_ios_rep = stub()
......@@ -421,7 +426,7 @@ module Pod
it "returns the hook representation of a library" do
rep = @installer.send(:library_rep, @lib)
rep.send(:library).name.should == 'Pods'
rep.send(:library).name.should == 'Pods-JSONKit'
end
it "returns the hook representation of all the pods" do
......@@ -431,12 +436,12 @@ module Pod
it "returns the hook representation of all the target installers" do
reps = @installer.send(:library_reps)
reps.map(&:name).should == ['Pods']
reps.map(&:name).sort.should == ['Pods', 'Pods-JSONKit'].sort
end
it "returns the libraries which use a given Pod" do
libs = @installer.send(:libraries_using_spec, @spec)
libs.map(&:name).should == ['Pods']
libs.map(&:name).should == ['Pods-JSONKit']
end
end
......
require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Pod::Library do
describe Pod::Target do
describe "In general" do
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@lib = Library.new(@target_definition)
@lib = Target.new(@target_definition, config.sandbox)
end
it "returns the target_definition that generated it" do
......@@ -31,7 +31,7 @@ module Pod
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@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.client_root = config.sandbox.root.dirname
end
......
......@@ -27,10 +27,6 @@ module Pod
@sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers'
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
@sandbox.implode
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