Sha256: 32ec267d2ad3464145af87dca502126f2164e162addab6e020e1b01af3361970

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'
require 'tmpdir'
require 'fileutils'

describe 'CocoaPodsKeys functional tests' do
  before :all do
    @tmpdir = Dir.mktmpdir
    Dir.chdir(@tmpdir) do
      FileUtils.mkdir('TestProject.xcodeproj')
      File.open('Podfile', 'w') do |podfile|
        podfile.puts <<-PODFILE
          platform :ios, '7'
          plugin 'cocoapods-keys', {
              :project => 'TestProject',
              :keys => [
                  'KeyWithData',
                  'AnotherKeyWithData',
                  # This is not included!
                  # 'UnusedKey'
              ]
          }
        PODFILE
      end

      system('pod keys set KeyWithData such-data --silent')
      system('pod keys set AnotherKeyWithData other-data --silent')
      system('pod keys set UnusedKey - --silent')
      system('pod install --silent --no-repo-update --no-integrate')
    end
  end

  it 'does not directly encode the keys into the implementation file' do
    source = File.read(File.join(@tmpdir, 'Pods/CocoaPodsKeys/TestProjectKeys.m'))
    expect(source).to_not include('such-data')
    expect(source).to_not include('other-data')
  end

  it 'is able to retrieve the correct keys from the command-line' do
    Dir.chdir(@tmpdir) do
      expect(`pod keys get KeyWithData`.strip).to eq('such-data')
      expect(`pod keys get AnotherKeyWithData`.strip).to eq('other-data')
    end
  end

  describe 'with a built keys implementation' do
    before :all do
      name = 'TestProjectKeys'
      dir = File.join(@tmpdir, 'Pods/CocoaPodsKeys')
      Dir.chdir(dir) do
        system("xcrun clang -framework Foundation -bundle #{name}.m -o #{name}.bundle")
      end
      @bundle = File.join(dir, "#{name}.bundle")
    end

    private

    def fetch_key(key)
      result = `'#{fixture('dump-key')}' '#{@bundle}' #{key}`.strip
      raise 'Failed to fetch key from bundle' unless $?.success?
      result
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cocoapods-keys-1.4.0 spec/functional_spec.rb
cocoapods-keys-1.3.2 spec/functional_spec.rb
cocoapods-keys-1.3.1 spec/functional_spec.rb
cocoapods-keys-1.3.0 spec/functional_spec.rb