From 175795b2b2ce548f45c1a97c045d13f36dec01fc Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Mon, 5 May 2025 15:54:40 -0600 Subject: [PATCH] Added container settings registration Necessary to provide application wide access to the configuration which will soon be shared by the newly renamed requester and client (not implemented yet). Milestone: minor --- lib/trmnl/api/container.rb | 1 + .../shared_contexts/application_dependencies.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/trmnl/api/container.rb b/lib/trmnl/api/container.rb index c71b82f..ca42440 100644 --- a/lib/trmnl/api/container.rb +++ b/lib/trmnl/api/container.rb @@ -10,6 +10,7 @@ module TRMNL module Container extend Containable + register(:settings) { TRMNL::API::Configuration::Loader.new.call } register(:requester) { API::Requester.new } register(:logger) { Cogger.new id: "trmnl-api", formatter: :json } diff --git a/spec/support/shared_contexts/application_dependencies.rb b/spec/support/shared_contexts/application_dependencies.rb index f9d9d2a..6cb2bd0 100644 --- a/spec/support/shared_contexts/application_dependencies.rb +++ b/spec/support/shared_contexts/application_dependencies.rb @@ -1,9 +1,17 @@ # frozen_string_literal: true RSpec.shared_context "with application dependencies" do - let(:logger) { Cogger.new id: "trmnl-api", io: StringIO.new, level: :debug } + let :settings do + TRMNL::API::Configuration::Content[ + content_type: "application/json", + uri: "https://trmnl.app/api" + ] + end - before { TRMNL::API::Container.stub! http:, logger: } + let(:logger) { Cogger.new id: "trmnl-api", io: StringIO.new, level: :debug } + let(:http) { class_spy HTTP } + + before { TRMNL::API::Container.stub! settings:, http:, logger: } after { TRMNL::API::Container.restore } end