1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
require "spec_helper"
describe "Fog::StringifyKeys" do
describe ".stringify" do
describe "when key is a Symbol" do
it "replaces key with String" do
input = { :key => "value" }
output = Fog::StringifyKeys.stringify(input)
assert(output.key?("key"))
end
end
describe "when key is a String" do
it "keeps key as String" do
input = { "key" => "value" }
output = Fog::StringifyKeys.stringify(input)
assert(output.key?("key"))
end
end
describe "when Hash is empty" do
it "returns empty Hash" do
assert_equal({}, Fog::StringifyKeys.stringify({}))
end
end
describe "when keys are deeply nested" do
it "updates only top level key" do
input = { :key1 => { :key2 => { :key3 => nil }}}
output = Fog::StringifyKeys.stringify(input)
expected = { "key1" => { :key2 => { :key3 => nil }}}
assert_equal(expected, output)
end
end
end
end
|