Commit b27e1d2c authored by Eloy Duran's avatar Eloy Duran

Finish installer and integration specs.

parent 3655f6e5
...@@ -71,7 +71,7 @@ module Pod ...@@ -71,7 +71,7 @@ module Pod
end end
def write_files! def write_files!
xproj.create_in(config.project_pods_root) xcodeproj.create_in(config.project_pods_root)
xcconfig.create_in(config.project_pods_root) xcconfig.create_in(config.project_pods_root)
end end
end end
......
...@@ -24,12 +24,25 @@ module Pod ...@@ -24,12 +24,25 @@ module Pod
@template @template
end end
def find_object(conditions) def find_objects(conditions)
objects.find do |_, object| objects.select do |_, object|
object.objectsForKeys(conditions.keys, notFoundMarker:Object.new) == conditions.values object.objectsForKeys(conditions.keys, notFoundMarker:Object.new) == conditions.values
end end
end end
def find_object(conditions)
find_objects(conditions).first
end
def source_files
conditions = { 'isa' => 'PBXFileReference', 'sourceTree' => 'SOURCE_ROOT' }
find_objects(conditions).map do |_, object|
if %w{ .h .m .mm .c .cpp }.include?(File.extname(object['path']))
Pathname.new(object['path'])
end
end.compact
end
def add_source_file(file) def add_source_file(file)
file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT') file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT')
add_file_to_group(file_ref_uuid, 'Pods') add_file_to_group(file_ref_uuid, 'Pods')
......
...@@ -50,11 +50,17 @@ else ...@@ -50,11 +50,17 @@ else
installer = SpecHelper::Installer.new(spec) installer = SpecHelper::Installer.new(spec)
installer.install! installer.install!
(config.project_pods_root + 'Reachability.podspec').should.exist root = config.project_pods_root
(config.project_pods_root + 'ASIHTTPRequest.podspec').should.exist (root + 'Reachability.podspec').should.exist
(config.project_pods_root + 'ASIWebPageRequest.podspec').should.exist (root + 'ASIHTTPRequest.podspec').should.exist
(config.project_pods_root + 'JSONKit.podspec').should.exist (root + 'ASIWebPageRequest.podspec').should.exist
(config.project_pods_root + 'SSZipArchive.podspec').should.exist (root + 'JSONKit.podspec').should.exist
(root + 'SSZipArchive.podspec').should.exist
(root + 'Pods.xcconfig').read.should == installer.xcconfig.to_s
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
NSDictionary.dictionaryWithContentsOfFile(project_file).should == installer.xcodeproj.to_hash
puts "\n[!] Compiling static library..." puts "\n[!] Compiling static library..."
Dir.chdir(config.project_pods_root) do Dir.chdir(config.project_pods_root) do
......
...@@ -17,28 +17,48 @@ describe "Pod::Installer" do ...@@ -17,28 +17,48 @@ describe "Pod::Installer" do
[ [
'ASIHTTPRequest', 'ASIHTTPRequest',
['Classes'], ['Classes'],
"{Classes,External/Reachability}/*.{h,m}" "{Classes,External/Reachability}/*.{h,m}",
{
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)",
"ALWAYS_SEARCH_USER_PATHS" => "YES",
"OTHER_LDFLAGS" => "-framework SystemConfiguration -framework CFNetwork " \
"-framework MobileCoreServices -l z.1.2.3"
}
], ],
[ [
'Reachability', 'Reachability',
["External/Reachability/*.h", "External/Reachability/*.m"], ["External/Reachability/*.h", "External/Reachability/*.m"],
"External/Reachability/*.{h,m}" "External/Reachability/*.{h,m}",
{
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)",
"ALWAYS_SEARCH_USER_PATHS" => "YES"
}
], ],
[ [
'ASIWebPageRequest', 'ASIWebPageRequest',
['**/ASIWebPageRequest.*'], ['**/ASIWebPageRequest.*'],
"{Classes,Classes/ASIWebPageRequest,External/Reachability}/*.{h,m}" "{Classes,Classes/ASIWebPageRequest,External/Reachability}/*.{h,m}",
{
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)",
"ALWAYS_SEARCH_USER_PATHS" => "YES",
"HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2",
"OTHER_LDFLAGS" => "-l xml2.2.7.3 -framework SystemConfiguration " \
"-framework CFNetwork -framework MobileCoreServices -l z.1.2.3"
}
], ],
].each do |name, patterns, expected_pattern| ].each do |name, patterns, expected_pattern, xcconfig|
Pod::Source.reset! Pod::Source.reset!
Pod::Spec::Set.reset! Pod::Spec::Set.reset!
installer = Pod::Installer.new(Pod::Spec.new { dependency(name); source_files(*patterns) }) installer = Pod::Installer.new(Pod::Spec.new { dependency(name); source_files(*patterns) })
expected = (stubbed_destroot(installer) + expected_pattern).glob.map do |file| expected = (stubbed_destroot(installer) + expected_pattern).glob.map do |file|
file.relative_path_from(config.project_pods_root) file.relative_path_from(config.project_pods_root)
end end
installer.generate_project
installer.source_files.size.should == expected.size installer.source_files.size.should == expected.size
installer.source_files.sort.should == expected.sort installer.source_files.sort.should == expected.sort
#installer.xproj.source_files.sort.should == expected.sort installer.xcodeproj.source_files.size.should == expected.size
installer.xcodeproj.source_files.sort.should == expected.sort
installer.xcconfig.to_hash.should == xcconfig
end end
end end
......
...@@ -66,4 +66,10 @@ describe "Pod::Xcode::Project" do ...@@ -66,4 +66,10 @@ describe "Pod::Xcode::Project" do
project_file = (temporary_directory + 'Pods.xcodeproj/project.pbxproj') project_file = (temporary_directory + 'Pods.xcodeproj/project.pbxproj')
NSDictionary.dictionaryWithContentsOfFile(project_file.to_s).should == @project.to_hash NSDictionary.dictionaryWithContentsOfFile(project_file.to_s).should == @project.to_hash
end end
it "returns all source files" do
files = [Pathname.new('/some/file.h'), Pathname.new('/some/file.m')]
files.each { |file| @project.add_source_file(file) }
@project.source_files.sort.should == files.sort
end
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