Sha256: 063a13468f60a5d79a885c036371ec7c8822ba0b5231d5e5fb9e7be095584d98

Contents?: true

Size: 731 Bytes

Versions: 12

Compression:

Stored size: 731 Bytes

Contents

require 'spec_helper'

describe Array do
  with_minimum_ruby('2.3.0') do
    describe '#dig' do
      let(:array) { Hashie::Array.new([:a, :b, :c]) }

      it 'works with a string index' do
        expect(array.dig('0')).to eq(:a)
      end

      it 'works with a numeric index' do
        expect(array.dig(1)).to eq(:b)
      end

      context 'when array is empty' do
        let(:array) { Hashie::Array.new([]) }

        it 'works with a first numeric and next string index' do
          expect(array.dig(0, 'hello')).to eq(nil)
        end

        it 'throws an error with first string and next numeric index' do
          expect { array.dig('hello', 0) }.to raise_error(TypeError)
        end
      end
    end
  end
end

Version data entries

12 entries across 11 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/hashie-3.5.7/spec/hashie/array_spec.rb
hashie-3.5.7 spec/hashie/array_spec.rb
hashie-3.5.6 spec/hashie/array_spec.rb
tdiary-5.0.5 vendor/bundle/gems/hashie-3.5.5/spec/hashie/array_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/hashie-3.5.5/spec/hashie/array_spec.rb
tdiary-5.0.4 vendor/bundle/gems/hashie-3.5.5/spec/hashie/array_spec.rb
hashie-3.5.5 spec/hashie/array_spec.rb
hashie-3.5.4 spec/hashie/array_spec.rb
hashie-3.5.3 spec/hashie/array_spec.rb
hashie-3.5.2 spec/hashie/array_spec.rb
hashie-3.5.1 spec/hashie/array_spec.rb
hashie-3.5.0 spec/hashie/array_spec.rb