Skip to content

Commit

Permalink
put additional params in scope when evaluating bootstrap DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
pghalliday committed Oct 28, 2015
1 parent 0f6e699 commit d567aa2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 12 additions & 1 deletion lib/formatron/configuration/formatronfile/dsl/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ class Formatronfile
class DSL
# DSL for the Formatronfile bootstrap section
class Bootstrap
def initialize(_target, _config, block)
attr_reader(
:target,
:config,
:name,
:bucket
)

def initialize(target, config, name, bucket, block)
@target = target
@config = config
@name = name
@bucket = bucket
instance_eval(&block)
end

Expand Down
14 changes: 11 additions & 3 deletions spec/formatron/configuration/formatronfile/dsl/bootstrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@

block = proc do
protect true
kms_key 'kms_key'
kms_key "#{target}-#{config['kms_key']}-#{name}-#{bucket}"
end
target = 'target'
config = {}
config = {
'kms_key' => 'kms_key'
}
name = 'name'
bucket = 'bucket'

before(:each) do
@bootstrap = Formatron::Configuration::Formatronfile::DSL::Bootstrap.new(
target,
config,
name,
bucket,
block
)
end
Expand All @@ -27,7 +33,9 @@

describe '#kms_key' do
it 'should set the kms_key property' do
expect(@bootstrap.kms_key).to eql 'kms_key'
expect(@bootstrap.kms_key).to eql(
"#{target}-#{config['kms_key']}-#{name}-#{bucket}"
)
end
end
end

0 comments on commit d567aa2

Please sign in to comment.