spec/celsius/hash_spec.rb in celsius-0.4.1 vs spec/celsius/hash_spec.rb in celsius-0.4.2
- old
+ new
@@ -56,9 +56,24 @@
expect(described_class.deep_find_key(hash, [:facets, :creator])).to eq(expected_result)
end
end
end
+ describe ".smart_fetch" do
+ let(:hash) do
+ {
+ foo: "bar",
+ muff: false
+ }
+ end
+
+ it "fetches a value by key indifferently from the given hash" do
+ expect(described_class.smart_fetch(hash, :foo)).to eq(hash[:foo])
+ expect(described_class.smart_fetch(hash, "foo")).to eq(hash[:foo])
+ expect(described_class.smart_fetch(hash, "muff")).to eq(hash[:muff])
+ end
+ end
+
describe ".smart_store" do
it "stores a value with the given key" do
expect(described_class.smart_store({}, :key, "value")).to eq({key: "value"})
end