Sha256: 073cfba4227b2eac144abfd31808c9d0db09510c5d5a58c836d0f66d27c9f362

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

describe HashPresenter::Observable do

  extend BaseHashPresenterTest
  test_presenter(HashPresenter::Observable)

  context 'Special Behavior' do

    it 'should observe an attribute object' do
      original = { a: 2 }
      hp = HashPresenter::Observable.new(original)

      expect(hp.a).to eq(2)

      original[:a] = 3

      expect(hp.a).to eq(3)

      original[:a] = { b: 1 }

      expect(hp.a.b).to eq(1)

      original[:c] = 4

      expect(hp.c).to eq(4)
    end

    it 'should regenerate method result for a nested hash' do
      hp = HashPresenter::Observable.new(a: { b: 1 })
      expect(hp.a.object_id).to_not eq(hp.a.object_id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tarvit-helpers-0.0.23 spec/modules/hash_presenter/observable_spec.rb
tarvit-helpers-0.0.22 spec/modules/hash_presenter/observable_spec.rb
tarvit-helpers-0.0.21 spec/modules/hash_presenter/observable_spec.rb
tarvit-helpers-0.0.20 spec/modules/hash_presenter/observable_spec.rb