Skip to content

Commit

Permalink
more specs. raise if target and target_proxy are nil
Browse files Browse the repository at this point in the history
  • Loading branch information
benasher44 committed Jul 18, 2016
1 parent 56f70d3 commit 5a24a39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/xcodeproj/project/object/target_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def display_name
def native_target_uuid
return target.uuid if target
return target_proxy.remote_global_id_string if target_proxy
raise 'Expected target or target_proxy, from which to fetch a uuid'
end

# @note This override is necessary because Xcode allows for circular
Expand Down
31 changes: 31 additions & 0 deletions spec/project/object/target_dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,36 @@ module ProjectSpecs
end

#----------------------------------------#

describe '#native_target_uuid' do
it "returns the target_proxy's remote_global_uuid_string" do
target = @project.new_target(:static, 'Pods', :ios)

proxy = @project.new(PBXContainerItemProxy)
proxy.container_portal = @project.root_object.uuid
proxy.remote_info = 'Pods'
proxy.proxy_type = '1'
proxy.remote_global_id_string = target.uuid

@target_dependency.target_proxy = proxy
@target_dependency.target_proxy.remote_global_id_string.nil?.should == false
@target_dependency.native_target_uuid.should == @target_dependency.target_proxy.remote_global_id_string
end

it "returns the target's uuid" do
target = @project.new_target(:static, 'Pods', :ios)
@target_dependency.target = target
@target_dependency.target.uuid.nil?.should == false
@target_dependency.native_target_uuid.should == @target_dependency.target.uuid
end

it "raises if target and target_proxy aren't set" do
@target_dependency.target.nil?.should == true
@target_dependency.target_proxy.nil?.should == true
should.raise do
@target_dependency.native_target_uuid
end.message.should.match /Expected target or target_proxy, from which to fetch a uuid/
end
end
end
end

0 comments on commit 5a24a39

Please sign in to comment.