Skip to content

Commit

Permalink
Merge pull request #47 from chef/tm/re_chefstyle
Browse files Browse the repository at this point in the history
Fix chefstyle bustage
  • Loading branch information
thommay committed Dec 6, 2016
2 parents d63ee1c + 4e9c30c commit 274562f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions lib/mixlib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def config_context_list(plural_symbol, singular_symbol, &block)
unless config_context_lists.has_key?(plural_symbol)
config_context_lists[plural_symbol] = {
definition_blocks: [],
values: []
values: [],
}
define_list_attr_accessor_methods(plural_symbol, singular_symbol)
end
Expand Down Expand Up @@ -424,7 +424,7 @@ def config_context_hash(plural_symbol, singular_symbol, &block)
unless config_context_hashes.has_key?(plural_symbol)
config_context_hashes[plural_symbol] = {
definition_blocks: [],
values: {}
values: {},
}
define_hash_attr_accessor_methods(plural_symbol, singular_symbol)
end
Expand Down Expand Up @@ -613,12 +613,12 @@ def define_hash_attr_accessor_methods(plural_symbol, singular_symbol)
meta.send :define_method, singular_symbol do |key, &block|
context_hash_details = internal_get(plural_symbol)
context = if context_hash_details[:values].has_key? key
context_hash_details[:values][key]
else
new_context = define_context(context_hash_details[:definition_blocks])
context_hash_details[:values][key] = new_context
new_context
end
context_hash_details[:values][key]
else
new_context = define_context(context_hash_details[:definition_blocks])
context_hash_details[:values][key] = new_context
new_context
end
# If the block expects no arguments, then instance_eval
if block.arity == 0
context.instance_eval(&block)
Expand Down
40 changes: 20 additions & 20 deletions spec/mixlib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1028,12 +1028,12 @@ class StrictClass3
end
klass
end
it 'defines list methods when declaring a config_context_list' do
it "defines list methods when declaring a config_context_list" do
expect(klass.methods).to include :test
expect(klass.methods).to include :tests
end

it 'creates a new item each time the singular list is called' do
it "creates a new item each time the singular list is called" do
klass.test do
y 40
end
Expand All @@ -1045,7 +1045,7 @@ class StrictClass3
expect(klass.tests.last.y).to be 50
end

it 'can save the config list' do
it "can save the config list" do
klass.test do
y 40
end
Expand All @@ -1055,17 +1055,17 @@ class StrictClass3
expect(klass.save).to eq({
tests: [
{ y: 40 },
{ y: 50 }
]
{ y: 50 },
],
})
end

it 'can restore the config list from a hash' do
it "can restore the config list from a hash" do
hash = {
tests: [
{ y: 40 },
{ y: 50 }
]
{ y: 50 },
],
}
klass.restore(hash)
expect(klass.tests.length).to be 2
Expand All @@ -1074,7 +1074,7 @@ class StrictClass3
end
end

describe 'config context hashes' do
describe "config context hashes" do
let(:klass) do
klass = Class.new
klass.extend ::Mixlib::Config
Expand All @@ -1086,13 +1086,13 @@ class StrictClass3
klass
end

it 'defines list methods when declaring a config_context_hash' do
it "defines list methods when declaring a config_context_hash" do
expect(klass.methods).to include :test
expect(klass.methods).to include :tests
end

context 'when called with a new key each time' do
it 'creates a new item each time' do
context "when called with a new key each time" do
it "creates a new item each time" do
klass.test :one do
y 40
end
Expand All @@ -1104,8 +1104,8 @@ class StrictClass3
expect(klass.tests[:two].y).to be 50
end
end
context 'when called with the same key' do
it 'modifies the existing value' do
context "when called with the same key" do
it "modifies the existing value" do
klass.test :only do
y 40
end
Expand All @@ -1117,7 +1117,7 @@ class StrictClass3
end
end

it 'can save the config hash' do
it "can save the config hash" do
klass.test :one do
y 40
end
Expand All @@ -1127,17 +1127,17 @@ class StrictClass3
expect(klass.save).to eq({
tests: {
one: { y: 40 },
two: { y: 50 }
}
two: { y: 50 },
},
})
end

it 'can restore the config hash from a hash' do
it "can restore the config hash from a hash" do
hash = {
tests: {
one: { y: 40 },
two: { y: 50 }
}
two: { y: 50 },
},
}
klass.restore(hash)
expect(klass.tests.length).to be 2
Expand Down

0 comments on commit 274562f

Please sign in to comment.