Sha256: 5727a7fe7566014e9f78027e2eaec8ef9deaaf430a3398096c2573f3f20e71b3

Contents?: true

Size: 805 Bytes

Versions: 4

Compression:

Stored size: 805 Bytes

Contents

require 'spec_helper'
require 'observed/hash/builder'

describe Observed::Hash::Builder do

  subject {
    described_class.new(hash)
  }

  context 'with a source hash' do

    let(:hash) { {} }

    context 'with a key path' do
      it 'decodes the key path and recursively creates missing Hash object for each part in the key path' do
        subject['foo.bar'] = 1

        expect(subject.build).to eq({foo:{bar:1}})
      end
    end

    context 'with a regular string key' do
      it 'updates the value for the key' do
        subject['foo'] = 1
        expect(subject.build).to eq({foo:1})
      end
    end

    context 'with a regular symbol key' do
      it 'updates the value for the key' do
        subject[:foo] = 1
        expect(subject.build).to eq({foo:1})
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
observed-0.2.0 spec/hash/builder_spec.rb
observed-0.2.0.rc2 spec/hash/builder_spec.rb
observed-0.2.0.rc1 spec/hash/builder_spec.rb
observed-0.1.1 spec/hash/builder_spec.rb