Skip to content

Commit 01e4c83

Browse files
authored
Merge pull request #11 from intercom/james/builder_spec
Clean when building + specs
2 parents 26357fe + 70ab185 commit 01e4c83

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

lib/cocoapods_mangle/builder.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module CocoapodsMangle
55
#
66
# This is useful for building pods for mangling purposes
77
class Builder
8-
BUILT_PRODUCTS_DIR = 'build/Release-iphonesimulator'
8+
BUILD_DIR = 'build'
9+
BUILT_PRODUCTS_DIR = "#{BUILD_DIR}/Release-iphonesimulator"
910

1011
# @param [String] pods_project_path
1112
# path to the pods project to build.
@@ -19,7 +20,7 @@ def initialize(pods_project_path, pod_target_labels)
1920

2021
# Build the pods project
2122
def build!
22-
FileUtils.remove_dir(BUILT_PRODUCTS_DIR, true)
23+
FileUtils.remove_dir(BUILD_DIR, true)
2324
@pod_target_labels.each { |target| build_target(target) }
2425
end
2526

spec/unit/builder_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)