Sha256: b778f8aacb3c76d8e0f5981f0b05b6a1aa8ce76e1b13bcbcf687f332e3b5c4f6
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' describe BottomlessHash do subject { described_class.new } it 'does not raise on missing key' do expect do subject[:missing][:key] end.to_not raise_error end it 'returns an empty value on missing key' do expect(subject[:missing][:key]).to be_empty end it 'stores and returns keys' do subject[:existing][:key] = :value expect(subject[:existing][:key]).to eq :value end describe '#from_hash' do let (:hash) do { existing: { key: { value: :hello } } } end subject do described_class.from_hash(hash) end it 'returns old hash values' do expect(subject[:existing][:key][:value]).to eq :hello end it 'provides a bottomless version' do expect(subject[:missing][:key]).to be_empty end it 'stores and returns new values' do subject[:existing][:key] = :value expect(subject[:existing][:key]).to eq :value end it 'converts nested hashes as well' do expect do subject[:existing][:key][:missing] end.to_not raise_error end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hash_easy-0.0.3 | spec/hash_easy/bottomless_hash_spec.rb |
hash_easy-0.0.2 | spec/hash_easy/bottomless_hash_spec.rb |
hash_easy-0.0.1 | spec/hash_easy/bottomless_hash_spec.rb |