-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild_phase_node_spec.rb
95 lines (85 loc) · 3.01 KB
/
build_phase_node_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require "spec_helper"
describe XcodeProject::BuildPhaseNode do
let(:root) { prepare_example_project.read.send(:root) }
let(:file_ref) { root.project.main_group.file_ref('group1a/file2c.m') }
let(:build_file) { root.project.target('example').sources_build_phase.send(:build_file, file_ref.uuid) }
let(:obj) { obj = root.project.target('example').sources_build_phase }
describe "#files" do
it "returns an array of files" do
obj.files.should be_an_instance_of(Array)
obj.files.each {|obj| obj.should be_an_instance_of(XcodeProject::PBXFileReference) }
end
end
describe "#add_file" do
context "if passed an object of the PBXFileReference type" do
it "=> add_build_file" do
mock(obj).add_build_file(file_ref.uuid)
obj.add_file(file_ref)
end
end
context "if passed an object of the PBXBuildFile type" do
it "=> add_build_file_uuid" do
mock(obj).add_build_file_uuid(build_file.uuid)
obj.add_file(build_file)
end
end
context "if passed the object of unsupported type" do
it "raise an exception" do
lambda { obj.add_file(stub) }.should raise_exception(ArgumentError)
end
end
end
describe "#remove_file" do
context "if passed an object of the PBXFileReference type" do
it "=> remove_build_file_uuid" do
mock(obj).remove_build_file_uuid(root.project.target('example').sources_build_phase.send(:build_file, file_ref.uuid).uuid)
obj.remove_file(file_ref)
end
end
context "if passed an object of the PBXBuildFile type" do
it "=> remove_build_file_uuid" do
mock(obj).remove_build_file_uuid(build_file.uuid)
obj.remove_file(build_file)
end
end
context "if passed the object of unsupported type" do
it "raise an exception" do
lambda { obj.remove_file(stub) }.should raise_exception(ArgumentError)
end
end
end
describe "#build_files" do
it "returns an array of files" do
obj.send(:build_files).should be_an_instance_of(Array)
obj.send(:build_files).each {|obj| obj.should be_an_instance_of(XcodeProject::PBXBuildFile) }
end
end
describe "#build_file" do
it "returns the object" do
obj.send(:build_file, file_ref.uuid).should be_an_instance_of(XcodeProject::PBXBuildFile)
end
end
describe "#add_build_file" do
it "adds the build file, returns the object" do
obj.send(:add_build_file, file_ref.uuid).should be_an_instance_of(XcodeProject::PBXBuildFile)
end
end
describe "#remove_build_file" do
it "=> remove_build_file_uuid" do
mock(obj).remove_build_file_uuid(build_file.uuid)
obj.send(:remove_build_file, file_ref.uuid)
end
end
describe "#add_build_file_uuid" do
it "adds the build file uuid to the build list" do
obj.send(:add_build_file_uuid, build_file.uuid)
obj.send(:build_files).map {|obj| obj.uuid }.should include(build_file.uuid)
end
end
describe "#remove_build_file_uuid" do
it "removes the build file uuid from the build list" do
obj.send(:remove_build_file_uuid, build_file.uuid)
obj.send(:build_files).map {|obj| obj.uuid }.should_not include(build_file.uuid)
end
end
end