require File.expand_path('../spec_helper.rb', __FILE__) require 'xcodeproj' describe CocoaPodsGitlabLicenseReport do UmbrellaTargetDescription = Pod::Installer::PostInstallHooksContext::UmbrellaTargetDescription PostInstallHookHandler = CocoaPodsGitlabLicenseReport::PostInstallHookHandler before do @sandbox = temporary_sandbox @spec1 = SpecHelper.spec1 @spec2 = SpecHelper.spec2 end describe PostInstallHookHandler do before do @target_description = UmbrellaTargetDescription.new(@project, [@target], [@spec1, @spec2], :ios, '8.0', 'Pods-MyApp') @hook_context = Pod::Installer::PostInstallHooksContext.new(@sandbox, @sandbox.root, nil, [@target_description]) end it 'Registers as cocoapods post_install hook' do expect_any_instance_of(PostInstallHookHandler).to receive(:initialize).with(@hook_context, {}) expect_any_instance_of(PostInstallHookHandler).to receive(:handle!) Pod::HooksManager.run(:post_install, @hook_context, { 'cocoapods-gitlab_license_report' => {}}) end it 'Passes options from the plugin def' do options = {:opt1 => "val1", :opt2 => "val2"} expect_any_instance_of(PostInstallHookHandler).to receive(:initialize).with(@hook_context, options) expect_any_instance_of(PostInstallHookHandler).to receive(:handle!) Pod::HooksManager.run(:post_install, @hook_context, { 'cocoapods-gitlab_license_report' => options}) end # it 'generates a settings plist when specified' do # settings_bundle = SpecHelper.temporary_directory + 'Settings.bundle' # settings_plist_path = settings_bundle + 'Pods-MyApp-settings-metadata.plist' # FileUtils.mkdir(settings_bundle) # resource_group = @project.main_group.new_group('Resources') # resource_group.new_file(settings_bundle) # # CocoaPodsAcknowledgements.expects(:save_metadata).with(@plist_content, @plist_path, @project, @sandbox, @target.uuid).once # CocoaPodsAcknowledgements.expects(:save_metadata).with(@settings_plist_content, settings_plist_path.to_s, @project, @sandbox, @target.uuid).once # Pod::HooksManager.run(:post_install, @hook_context, { 'cocoapods-acknowledgements' => { :settings_bundle => true }}) # FileUtils.rm_rf(settings_bundle) # end # # it "generates acknowledgement plists to only specified targets" do # CocoaPodsAcknowledgements.expects(:save_metadata).with(@plist_content, @plist_path, @project, @sandbox, @target.uuid).once # Pod::HooksManager.run(:post_install, @hook_context, { 'cocoapods-acknowledgements' => { targets: ['MyApp'] }}) # # CocoaPodsAcknowledgements.expects(:save_metadata).never # Pod::HooksManager.run(:post_install, @hook_context, { 'cocoapods-acknowledgements' => { targets: ['TheOtherTarget'] }}) # end end end