|
| 1 | +require File.expand_path('../../spec_helper', __FILE__) |
| 2 | +require 'cocoapods_mangle/builder' |
| 3 | + |
| 4 | +describe CocoapodsMangle::Builder do |
| 5 | + let(:pods_project_path) { 'path/to/Pods.xcodeproj' } |
| 6 | + let(:pod_target_labels) { %w[Pod-A Pod-B] } |
| 7 | + let(:subject) { CocoapodsMangle::Builder.new(pods_project_path, pod_target_labels) } |
| 8 | + |
| 9 | + context '.build!' do |
| 10 | + before do |
| 11 | + allow(FileUtils).to receive(:remove_dir).with(CocoapodsMangle::Builder::BUILD_DIR, true) |
| 12 | + end |
| 13 | + |
| 14 | + it 'builds' do |
| 15 | + expect(FileUtils).to receive(:remove_dir).with(CocoapodsMangle::Builder::BUILD_DIR, true) |
| 16 | + expect(subject).to receive(:build_target).with('Pod-A') |
| 17 | + expect(subject).to receive(:build_target).with('Pod-B') |
| 18 | + subject.build! |
| 19 | + end |
| 20 | + end |
| 21 | + |
| 22 | + context '.binaries_to_mangle' do |
| 23 | + let(:static_binaries) { %w[path/to/staticA.a path/to/staticB.a] } |
| 24 | + let(:frameworks) { %w[path/to/FrameworkA.framework path/to/FrameworkB.framework] } |
| 25 | + let(:framework_binaries) do |
| 26 | + frameworks.map { |path| "#{path}/#{File.basename(path, '.framework')}" } |
| 27 | + end |
| 28 | + before do |
| 29 | + allow(Dir).to receive(:glob) |
| 30 | + .with("#{CocoapodsMangle::Builder::BUILT_PRODUCTS_DIR}/**/*.a") |
| 31 | + .and_return(static_binaries + ['path/to/libPods-A.a']) |
| 32 | + allow(Dir).to receive(:glob) |
| 33 | + .with("#{CocoapodsMangle::Builder::BUILT_PRODUCTS_DIR}/**/*.framework") |
| 34 | + .and_return(frameworks + ['path/to/Pods_A.framework']) |
| 35 | + end |
| 36 | + |
| 37 | + it 'gives the static and framework binaries' do |
| 38 | + binaries = static_binaries + framework_binaries |
| 39 | + expect(subject.binaries_to_mangle).to match_array(binaries) |
| 40 | + end |
| 41 | + end |
| 42 | +end |
0 commit comments