test/test_keyargs.rb in muack-1.5.0 vs test/test_keyargs.rb in muack-1.5.1

- old
+ new

@@ -106,6 +106,55 @@ returns{ |a:| a } expect(Obj.say(a: 0)).eq(Obj.object_id) end end + + describe 'proxy new' do + would 'handle initialize via ordinal new' do + kargs_initialize = Class.new do + def initialize a: + @a = a + end + attr_reader :a + end + + mock(kargs_initialize).new(a: 0) + + expect(kargs_initialize.new(a: 0).a).eq(0) + end + + would 'handle overridden new without keyword arguments' do + kargs_initialize = Class.new do + def initialize a: + @a = a + end + attr_reader :a + + def self.new a + super(a: a) + end + end + + mock(kargs_initialize).new(0) + + expect(kargs_initialize.new(0).a).eq(0) + end + + would 'handle overridden new with keyword arguments' do + kargs_initialize = Class.new do + def initialize a + @a = a + end + attr_reader :a + + def self.new a: + super(a) + end + end + + mock(kargs_initialize).new(a: 0) + + expect(kargs_initialize.new(a: 0).a).eq(0) + end + end end