summaryrefslogtreecommitdiff
path: root/spec/ruby/core/struct/initialize_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/struct/initialize_spec.rb')
-rw-r--r--spec/ruby/core/struct/initialize_spec.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/ruby/core/struct/initialize_spec.rb b/spec/ruby/core/struct/initialize_spec.rb
index 06055594d5..c824f52e13 100644
--- a/spec/ruby/core/struct/initialize_spec.rb
+++ b/spec/ruby/core/struct/initialize_spec.rb
@@ -4,7 +4,7 @@ require_relative 'fixtures/classes'
describe "Struct#initialize" do
it "is private" do
- StructClasses::Car.should have_private_instance_method(:initialize)
+ StructClasses::Car.private_instance_methods(true).should.include?(:initialize)
end
it 'allows valid Ruby method names for members' do
@@ -48,4 +48,27 @@ describe "Struct#initialize" do
positional_args.version.should == keyword_args.version
positional_args.platform.should == keyword_args.platform
end
+
+ it "accepts positional arguments with empty keyword arguments" do
+ data = StructClasses::Single.new(42, **{})
+
+ data.value.should == 42
+
+ data = StructClasses::Ruby.new("3.2", "OS", **{})
+
+ data.version.should == "3.2"
+ data.platform.should == "OS"
+ end
+
+ it "can be called via delegated ... from a prepended module" do
+ wrapper = Module.new do
+ def initialize(...)
+ super(...)
+ end
+ end
+
+ klass = Class.new(Struct.new(:a)) { prepend wrapper }
+ s = klass.new("x")
+ s.a.should == "x"
+ end
end