From aabe5f5b2347e236565336838b7cbe359a786bcb Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 5 Apr 2025 17:55:15 +0100 Subject: [PATCH] Complete the changes needed to support ruby 3.3 and 3.4 --- lib/plugins/aws/invoke-local/index.js | 2 +- .../plugins/aws/invoke-local/index.test.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/plugins/aws/invoke-local/index.js b/lib/plugins/aws/invoke-local/index.js index 6d4cb92cd2..a21dfadb9c 100644 --- a/lib/plugins/aws/invoke-local/index.js +++ b/lib/plugins/aws/invoke-local/index.js @@ -293,7 +293,7 @@ class AwsInvokeLocal { ); } - if (['ruby2.7', 'ruby3.2'].includes(runtime)) { + if (['ruby2.7', 'ruby3.2', 'ruby3.3', 'ruby3.4'].includes(runtime)) { const handlerComponents = handler.split(/\./); const handlerPath = handlerComponents[0]; const handlerName = handlerComponents.slice(1).join('.'); diff --git a/test/unit/lib/plugins/aws/invoke-local/index.test.js b/test/unit/lib/plugins/aws/invoke-local/index.test.js index 45f307b291..983c4f1534 100644 --- a/test/unit/lib/plugins/aws/invoke-local/index.test.js +++ b/test/unit/lib/plugins/aws/invoke-local/index.test.js @@ -489,6 +489,28 @@ describe('AwsInvokeLocal', () => { ).to.be.equal(true); }); + it('should call invokeLocalRuby when ruby3.3 runtime is set', async () => { + awsInvokeLocal.options.functionObj.runtime = 'ruby3.3'; + await awsInvokeLocal.invokeLocal(); + // NOTE: this is important so that tests on Windows won't fail + const runtime = process.platform === 'win32' ? 'ruby.exe' : 'ruby'; + expect(invokeLocalRubyStub.calledOnce).to.be.equal(true); + expect( + invokeLocalRubyStub.calledWithExactly(runtime, 'handler', 'hello', {}, undefined) + ).to.be.equal(true); + }); + + it('should call invokeLocalRuby when ruby3.4 runtime is set', async () => { + awsInvokeLocal.options.functionObj.runtime = 'ruby3.4'; + await awsInvokeLocal.invokeLocal(); + // NOTE: this is important so that tests on Windows won't fail + const runtime = process.platform === 'win32' ? 'ruby.exe' : 'ruby'; + expect(invokeLocalRubyStub.calledOnce).to.be.equal(true); + expect( + invokeLocalRubyStub.calledWithExactly(runtime, 'handler', 'hello', {}, undefined) + ).to.be.equal(true); + }); + it('should call invokeLocalDocker if using runtime provided', async () => { awsInvokeLocal.options.functionObj.runtime = 'provided'; awsInvokeLocal.options.functionObj.handler = 'handler.foobar';