Added configuration content

Necessary to configure the client.
This commit is contained in:
Brooke Kuhlmann
2025-04-22 14:24:32 -06:00
parent 57fa5a0092
commit bbd82f4d3c
2 changed files with 32 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# frozen_string_literal: true
module TRMNL
module API
module Configuration
# Provides API client configuration content.
Content = Struct.new :content_type, :uri do
def headers = {"Content-Type" => content_type}.compact
end
end
end
end
@@ -0,0 +1,20 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe TRMNL::API::Configuration::Content do
subject :content do
described_class[uri: "https://trmnl.app/api", content_type: "application/json"]
end
describe "#headers" do
it "answers HTTP headers when defined" do
expect(content.headers).to eq("Content-Type" => "application/json")
end
it "answers empty hash when none are available" do
content.content_type = nil
expect(content.headers).to eq({})
end
end
end