summaryrefslogtreecommitdiff
path: root/spec/ruby/core/struct
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-12-27 17:35:32 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-12-27 17:35:32 +0100
commit727c97da1977544c91b9b3677811da3a44af7d53 (patch)
tree4f027117edad10789db57ff4b83242753a89e39d /spec/ruby/core/struct
parent267bed0cd91711e2a8c79219e97431ba22137b01 (diff)
Update to ruby/spec@4ce9f41
Diffstat (limited to 'spec/ruby/core/struct')
-rw-r--r--spec/ruby/core/struct/deconstruct_keys_spec.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/ruby/core/struct/deconstruct_keys_spec.rb b/spec/ruby/core/struct/deconstruct_keys_spec.rb
index 41b9c31e02..f0a1f50ad3 100644
--- a/spec/ruby/core/struct/deconstruct_keys_spec.rb
+++ b/spec/ruby/core/struct/deconstruct_keys_spec.rb
@@ -43,11 +43,19 @@ ruby_version_is "2.7" do
s.deconstruct_keys([0] ).should == {0 => 10}
end
- it "ignores not existing attribute names" do
+ it "returns an empty hash when there are more keys than attributes" do
struct = Struct.new(:x, :y)
s = struct.new(1, 2)
- s.deconstruct_keys([:a, :b, :c]).should == {}
+ s.deconstruct_keys([:x, :y, :a]).should == {}
+ end
+
+ it "returns at first not existing attribute name" do
+ struct = Struct.new(:x, :y)
+ s = struct.new(1, 2)
+
+ s.deconstruct_keys([:a, :x]).should == {}
+ s.deconstruct_keys([:x, :a]).should == {x: 1}
end
it "accepts nil argument and return all the attributes" do