Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ def display_name
return path if path
super
end

def to_hash_as(method = :to_hash)
hash_as = super
excluded_keys_for_serialization_when_empty.each do |key|
if !hash_as[key].nil? && hash_as[key].empty?
hash_as.delete(key)
end
end
hash_as
end

# @return [Array<String>] array of keys to exclude from serialization when the value is empty
def excluded_keys_for_serialization_when_empty
%w(exceptions)
end
end
end
end
Expand Down
27 changes: 27 additions & 0 deletions spec/project/object/file_system_synchronized_root_group_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXFileSystemSynchronizedRootGroup do
before do
@project = Project.new('/path/to/Dummy.xcodeproj')
@root_group = @project.new(PBXFileSystemSynchronizedRootGroup)
end

describe '#to_hash' do
it "does not include exceptions in its hash if there aren't any" do
@root_group.to_hash['exceptions'].should.be.nil
end

it 'includes exceptions in its hash if it contains at least one' do
target = @project.new(PBXNativeTarget)
target.name = "TestTarget"

exception = @project.new(PBXFileSystemSynchronizedBuildFileExceptionSet)
exception.target = target
@root_group.exceptions << exception

@root_group.to_hash['exceptions'].should == [exception.uuid]
end
end
end
end