summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-12-06 18:47:20 +0000
committerThom May <thom@chef.io>2016-12-06 18:47:20 +0000
commit4e9c30c7b00219820d678b40f399cc847d1c6ea2 (patch)
tree562bfb2d4e628f48c0bf45e8f375fe92eb229998
parentd63ee1c58098fd876a0dbff01af86621c13f026d (diff)
downloadmixlib-config-tm/re_chefstyle.tar.gz
Fix chefstyle bustagetm/re_chefstyle
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r--lib/mixlib/config.rb16
-rw-r--r--spec/mixlib/config_spec.rb40
2 files changed, 28 insertions, 28 deletions
diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb
index 51c2160..56c14b3 100644
--- a/lib/mixlib/config.rb
+++ b/lib/mixlib/config.rb
@@ -392,7 +392,7 @@ module Mixlib
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
@@ -424,7 +424,7 @@ module Mixlib
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
@@ -613,12 +613,12 @@ module Mixlib
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)
diff --git a/spec/mixlib/config_spec.rb b/spec/mixlib/config_spec.rb
index 52d0ec9..3634466 100644
--- a/spec/mixlib/config_spec.rb
+++ b/spec/mixlib/config_spec.rb
@@ -1028,12 +1028,12 @@ describe Mixlib::Config do
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
@@ -1045,7 +1045,7 @@ describe Mixlib::Config do
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
@@ -1055,17 +1055,17 @@ describe Mixlib::Config do
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
@@ -1074,7 +1074,7 @@ describe Mixlib::Config do
end
end
- describe 'config context hashes' do
+ describe "config context hashes" do
let(:klass) do
klass = Class.new
klass.extend ::Mixlib::Config
@@ -1086,13 +1086,13 @@ describe Mixlib::Config do
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
@@ -1104,8 +1104,8 @@ describe Mixlib::Config do
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
@@ -1117,7 +1117,7 @@ describe Mixlib::Config do
end
end
- it 'can save the config hash' do
+ it "can save the config hash" do
klass.test :one do
y 40
end
@@ -1127,17 +1127,17 @@ describe Mixlib::Config do
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