Sha256: 5d776aedea3a8c744032fbf1431300f57c6babdfc9fb0e97fbd56607c9f7e014

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 Bytes

Contents

require 'spec_helper'

describe Rundeck::ObjectifiedHash do
  before do
    @hash = { a: 1, b: 2 }
    @obj_hash = Rundeck::ObjectifiedHash.new(@hash)
  end
  subject { @obj_hash }

  its(:a) { is_expected.to eq(@hash[:a]) }
  its(:b) { is_expected.to eq(@hash[:b]) }

  describe '#to_hash' do
    subject { @obj_hash.to_hash }

    it { is_expected.to eq(@hash) }
  end

  describe '#to_h' do
    subject { @obj_hash.to_hash }

    it { is_expected.to eq(@hash) }
  end

  context 'with nested hashes' do
    before do
      @hash = { a: 1, b: { c: 2, d: { e: 3 } } }
      @obj_hash = Rundeck::ObjectifiedHash.new(@hash)
    end
    subject { @obj_hash }

    describe 'b' do
      subject { @obj_hash.b }

      it { is_expected.to be_a Rundeck::ObjectifiedHash }
      its(:c) { is_expected.to eq(@hash[:b][:c]) }

      describe 'd' do
        subject { @obj_hash.b.d }

        it { is_expected.to be_a Rundeck::ObjectifiedHash }
        its(:e) { is_expected.to eq(@hash[:b][:d][:e]) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rundeck-0.0.3 spec/rundeck/objectified_hash_spec.rb
rundeck-0.0.3.pre spec/rundeck/objectified_hash_spec.rb
rundeck-0.0.2.pre spec/rundeck/objectified_hash_spec.rb
rundeck-0.0.1.pre spec/rundeck/objectified_hash_spec.rb