summaryrefslogtreecommitdiff
path: root/spec/ruby/core/struct/new_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/struct/new_spec.rb')
-rw-r--r--spec/ruby/core/struct/new_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/struct/new_spec.rb b/spec/ruby/core/struct/new_spec.rb
index 7c33489779..01231e85fb 100644
--- a/spec/ruby/core/struct/new_spec.rb
+++ b/spec/ruby/core/struct/new_spec.rb
@@ -130,6 +130,17 @@ describe "Struct.new" do
it "fails with too many arguments" do
lambda { StructClasses::Ruby.new('2.0', 'i686', true) }.should raise_error(ArgumentError)
end
+
+ it "passes a hash as a normal argument" do
+ type = Struct.new(:args)
+
+ obj = type.new(keyword: :arg)
+ obj2 = type.new(*[{keyword: :arg}])
+
+ obj.should == obj2
+ obj.args.should == {keyword: :arg}
+ obj2.args.should == {keyword: :arg}
+ end
end
ruby_version_is "2.5" do
@@ -163,6 +174,12 @@ describe "Struct.new" do
@struct_with_kwa.new("elefant", 4)
}.should raise_error(ArgumentError, /wrong number of arguments/)
end
+
+ it "raises ArgumentError when passed a single non-hash argument" do
+ -> {
+ @struct_with_kwa.new("elefant")
+ }.should raise_error(ArgumentError, /wrong number of arguments/)
+ end
end
end