mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Added configuration content
Necessary to configure the client.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user