diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-06-02 14:34:07 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-06-02 14:34:07 +0200 |
commit | 22e2a6a999b958efe5d84d9c7314e450fda82254 (patch) | |
tree | b2dc946cf2fe2c250d0583675e548c67dca3e71a /spec/ruby/core/struct/dig_spec.rb | |
parent | a4fbc7e2884ba694278adea3b32ddb8c2ac10efe (diff) |
Update to ruby/spec@a0b7d0d
Diffstat (limited to 'spec/ruby/core/struct/dig_spec.rb')
-rw-r--r-- | spec/ruby/core/struct/dig_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/core/struct/dig_spec.rb b/spec/ruby/core/struct/dig_spec.rb index 4e39e5a4ef..93a52dbbe1 100644 --- a/spec/ruby/core/struct/dig_spec.rb +++ b/spec/ruby/core/struct/dig_spec.rb @@ -10,6 +10,16 @@ describe "Struct#dig" do @instance.dig(:a, :a).should == { b: [1, 2, 3] } end + it "accepts String keys" do + @instance.dig('a', 'a').should == { b: [1, 2, 3] } + end + + it "returns the value by the index" do + instance = Struct.new(:a, :b).new(:one, :two) + instance.dig(0).should == :one + instance.dig(1).should == :two + end + it "returns the nested value specified if the sequence includes an index" do @instance.dig(:a, :a, :b, 0).should == 1 end |