summaryrefslogtreecommitdiff
path: root/spec/hashie/mash_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/hashie/mash_spec.rb')
-rw-r--r--spec/hashie/mash_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb
index fa4e47b..4629124 100644
--- a/spec/hashie/mash_spec.rb
+++ b/spec/hashie/mash_spec.rb
@@ -982,6 +982,7 @@ describe Hashie::Mash do
with_minimum_ruby('2.3.0') do
describe '#dig' do
subject { described_class.new(a: { b: 1 }) }
+
it 'accepts both string and symbol as key' do
expect(subject.dig(:a, :b)).to eq(1)
expect(subject.dig('a', 'b')).to eq(1)
@@ -994,6 +995,14 @@ describe Hashie::Mash do
expect(subject.dig('1', :b)).to eq(1)
end
end
+
+ context 'when the Mash wraps a Hashie::Array' do
+ it 'handles digging into an array' do
+ mash = described_class.new(alphabet: { first_three: Hashie::Array['a', 'b', 'c'] })
+
+ expect(mash.dig(:alphabet, :first_three, 0)).to eq 'a'
+ end
+ end
end
end