Commit 76fcc490 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'issue-246'

* issue-246:
  [Specs] Detect the target with the matching name.
  [TargetIntegrator] Detect the target with the matching name.
parents a9a1d332 e58b364d
......@@ -110,10 +110,15 @@ module Pod
def targets
@targets ||= begin
if link_with = @target_definition.link_with
# Find explicitly named targets.
# Find explicitly linked targets.
user_project.targets.select do |target|
link_with.include? target.name
end
elsif @target_definition.name != :default
# Find the target with the matching name.
target = user_project.targets.find { |target| target.name == @target_definition.name.to_s }
raise Informative, "Unable to find a target named `#{@target_definition.name.to_s}'" unless target
[target]
else
# Default to the first, which in a simple project is probably an app target.
[user_project.targets.first]
......
......@@ -57,6 +57,19 @@ describe Pod::Installer::UserProjectIntegrator do
lambda { @target_integrator.user_project_path }.should.raise Pod::Informative
end
it "uses the target with the same name if the name is different from `:default'" do
target_integrator = @integrator.target_integrators[1]
target_integrator.target_definition.stubs(:name).returns('TestRunner')
target_integrator.target_definition.stubs(:link_with).returns(nil)
target_integrator.targets.first.name.should == 'TestRunner'
end
it "it raises if it can't find a target with the same name" do
target_integrator = @integrator.target_integrators[1]
target_integrator.target_definition.stubs(:link_with).returns(nil)
lambda { target_integrator.targets }.should.raise Pod::Informative
end
it "uses the first target in the user's project if no explicit target is specified" do
@target_integrator.target_definition.stubs(:link_with).returns(nil)
@target_integrator.targets.should == [Xcodeproj::Project.new(@sample_project_path).targets.first]
......
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