8000 Remove empty `()` from PBXFileSystemSynchronizedRootGroup exceptions output by yimajo · Pull Request #1012 · CocoaPods/Xcodeproj · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove empty () from PBXFileSystemSynchronizedRootGroup exceptions output #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
0