Skip to content

Commit

Permalink
fix inherit configuration logic (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov authored May 27, 2020
1 parent 7c454ab commit 65714bc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/xcake/dsl/configuration/sugar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Configuration
#
# @example Using Supported Devices
#
# Target.new do |t|
# Target.new(project) do |t|
# t.all_configurations.each do |c|
# c.supported_devices = :ipad_only
# end
Expand Down
2 changes: 1 addition & 1 deletion lib/xcake/dsl/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def initialize(name = 'Project')
# the newly created target
#
def target(&block)
target = Target.new(&block)
target = Target.new(self, &block)
targets << target
target
end
Expand Down
8 changes: 6 additions & 2 deletions lib/xcake/dsl/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,19 @@ class Target
#
attr_accessor :schemes

# @param [Project] project
# the project the target belongs to.
#
# @param [Proc] block
# an optional block that configures the target through the DSL.
#
# @example Creating a Target.
#
# Target.new do |t|
# Target.new(project) do |t|
# t.name "test"
# end
#
def initialize
def initialize(project)
@pinned_build_phases = []
@build_phases = []
@build_rules = []
Expand All @@ -200,6 +203,7 @@ def initialize
@system_libraries = []
@target_dependencies = []
@schemes = []
@project = project

yield(self) if block_given?
end
Expand Down
3 changes: 2 additions & 1 deletion spec/dsl/target/sugar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module Xcake
describe Target do
before :each do
@target = Target.new
@project = Project.new
@target = Target.new(@project)
@build_phase_name = 'Hello World'
end

Expand Down
9 changes: 8 additions & 1 deletion spec/dsl/target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module Xcake
describe Target do
before :each do
@target = Target.new
@project = Project.new
@target = Target.new(@project)
@target.name = 'Test'
end

Expand Down Expand Up @@ -116,6 +117,12 @@ module Xcake
expect(@target.default_release_settings).to eq(settings)
end

it 'should inherit settings' do
@project.debug_configuration :Test
expect(@target.all_configurations.count).to eq(1)
expect(@target.all_configurations.first.name).to eq('Test')
end

it 'should initialize schemes' do
expect(@target.schemes).not_to be(nil)
end
Expand Down

0 comments on commit 65714bc

Please sign in to comment.