From 31242b9f6d3fa6737864f4e97d3592646a636b45 Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Fri, 11 Oct 2024 16:11:14 +0700 Subject: [PATCH] fix: cleanup entrypoint --- skyetel/app.rb | 16 ++-------------- skyetel/spec/app_spec.rb | 7 +------ skyetel/spec/support/lambda_helpers.rb | 11 ----------- 3 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 skyetel/spec/support/lambda_helpers.rb diff --git a/skyetel/app.rb b/skyetel/app.rb index 586089d..c78ef59 100644 --- a/skyetel/app.rb +++ b/skyetel/app.rb @@ -1,21 +1,9 @@ -require "logger" require_relative "config/application" module App class Handler - attr_reader :event, :context - - def self.process(event:, context:) - logger = Logger.new($stdout) - logger.info("## Processing Event") - logger.info(event) - - new(event:, context:).process - end - - def initialize(event:, context:) - @event = event - @context = context + def self.process(**) + new.process end def process diff --git a/skyetel/spec/app_spec.rb b/skyetel/spec/app_spec.rb index 54b3543..d46ba22 100644 --- a/skyetel/spec/app_spec.rb +++ b/skyetel/spec/app_spec.rb @@ -37,15 +37,10 @@ module App :post, "https://api.somleng.org/carrier/v1/phone_numbers", response_body: file_fixture("somleng/responses/create_phone_number.json").read ) - handler = build_handler - handler.process + App::Handler.process(event: {}, context: double("LambdaContext", as_json: {})) expect(a_request(:post, "https://api.somleng.org/carrier/v1/phone_numbers")).to have_been_made.times(2) end - - def build_handler(**options) - Handler.new(event: {}, context: double("LambdaContext", as_json: {}), **options) - end end end diff --git a/skyetel/spec/support/lambda_helpers.rb b/skyetel/spec/support/lambda_helpers.rb deleted file mode 100644 index ebccdd3..0000000 --- a/skyetel/spec/support/lambda_helpers.rb +++ /dev/null @@ -1,11 +0,0 @@ -module LambdaHelpers - def invoke_lambda(payload:) - context = double("LambdaContext", as_json: {}) - - App::Handler.process(event: payload, context:) - end -end - -RSpec.configure do |config| - config.include(LambdaHelpers) -end