Commit 3655f6e5 authored by Eloy Duran's avatar Eloy Duran

+ xcode config spec

parent d1ba2e80
......@@ -6,6 +6,10 @@ module Pod
merge!(xcconfig_hash)
end
def to_hash
@attributes
end
def merge!(xcconfig_hash)
xcconfig_hash.each do |key, value|
if existing_value = @attributes[key]
......@@ -17,12 +21,12 @@ module Pod
end
alias_method :<<, :merge!
def to_s
@attributes.map { |key, value| "#{key} = #{value}" }.join("\n")
end
def create_in(pods_root)
(pods_root + 'Pods.xcconfig').open('w') do |file|
@attributes.each do |key, value|
file.puts "#{key} = #{value}"
end
end
(pods_root + 'Pods.xcconfig').open('w') { |file| file << to_s }
end
end
end
......
require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Xcode::Config" do
extend SpecHelper::TemporaryDirectory
before do
@config = Pod::Xcode::Config.new('OTHER_LD_FLAGS' => '-framework Foundation')
end
it "merges another config hash in place" do
@config.merge!('HEADER_SEARCH_PATHS' => '/some/path')
@config.to_hash.should == {
'OTHER_LD_FLAGS' => '-framework Foundation',
'HEADER_SEARCH_PATHS' => '/some/path'
}
end
it "appends a value for the same key when merging" do
@config.merge!('OTHER_LD_FLAGS' => '-l xml2.2.7.3')
@config.to_hash.should == {
'OTHER_LD_FLAGS' => '-framework Foundation -l xml2.2.7.3'
}
end
it "creates the config file" do
@config.merge!('HEADER_SEARCH_PATHS' => '/some/path')
@config.merge!('OTHER_LD_FLAGS' => '-l xml2.2.7.3')
@config.create_in(temporary_directory)
(temporary_directory + 'Pods.xcconfig').read.split("\n").sort.should == [
"OTHER_LD_FLAGS = -framework Foundation -l xml2.2.7.3",
"HEADER_SEARCH_PATHS = /some/path"
].sort
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment