Sha256: b9ea27c87858074937db87e4b8aa336d6a7aea95a700817f38b1e911de6e51e5
Contents?: true
Size: 569 Bytes
Versions: 8
Compression:
Stored size: 569 Bytes
Contents
# frozen_string_literal: true require 'spec_helper' shared_examples 'a class that has a method to squash a hash' do describe '#squash' do let(:hash) { { a: { b: 1, c: { d: 2 } } } } it 'flattens the hash' do expect(squashed).to eq('a.b' => 1, 'a.c.d' => 2) end it { expect { hash.squash }.not_to(change { hash }) } context 'with array value' do let(:hash) { { a: { b: [1, { x: 3, y: { z: 4 } }] } } } it 'flattens the hash' do expect(squashed).to eq('a.b' => [1, { x: 3, y: { z: 4 } }]) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems