Skip to content

Commit

Permalink
Fix missing_method deprecation from Cheffish::MergedConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-barker committed Jun 16, 2018
1 parent 9e8fc5a commit c586d6f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/chef/provisioning/vsphere_driver/driver.rb
Expand Up @@ -56,7 +56,8 @@ def self.symbolize_keys(h)
#
# @param [Object] hash_like converts to key:value
def deep_symbolize(hash_like)
return {} if hash_like.nil? || hash_like.empty?
return {} if hash_like.nil?

r = {}
hash_like.each do |key, value|
value = deep_symbolize(value) if value.respond_to?(:values)
Expand Down
38 changes: 38 additions & 0 deletions spec/unit_tests/VsphereDriver_spec.rb
Expand Up @@ -220,4 +220,42 @@
end
end
end

context "#merge_options!" do
let(:metal_config) { {} }

it "Add tupple with string key" do
subject.merge_options! "string_key" => "some string"
expect(subject.config).to eq machine_options: {
string_key: "some string",
}
end

it "Add tupple with symbol key" do
subject.merge_options! symbol_key: "some other string"
expect(subject.config).to eq machine_options: {
symbol_key: "some other string",
}
end

it "Add empty MergedConfig" do
expect($stderr).not_to receive(:puts)

item = Cheffish::MergedConfig.new()
subject.merge_options! item

expect(subject.config).to eq machine_options: {}
end

it "Add MergedConfig with 1 tupple" do
expect($stderr).not_to receive(:puts)

item = Cheffish::MergedConfig.new(merged_config: "some merged value")
subject.merge_options! item

expect(subject.config).to eq machine_options: {
merged_config: "some merged value",
}
end
end
end

0 comments on commit c586d6f

Please sign in to comment.