Added empty recipe

Necessary to build an empty recipe (handy when needing to leverage the Null Object Pattern).

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-02-28 13:55:57 -07:00
parent 1b16e5f4ff
commit 047c4d1c94
2 changed files with 10 additions and 0 deletions
+2
View File
@@ -5,6 +5,8 @@ module TRMNL
module Models
# Models the payload of the API response.
Recipe = ::Data.define :data, :meta do
def self.empty(meta: Recipes::Meta.new) = new(data: [], meta:)
def self.for(**attributes)
meta = attributes.slice :from,
:to,
+8
View File
@@ -18,6 +18,14 @@ RSpec.describe TRMNL::API::Models::Recipe do
}
end
describe ".empty" do
it "answers empty record" do
expect(described_class.empty).to eq(
described_class[data: [], meta: TRMNL::API::Models::Recipes::Meta.new]
)
end
end
describe ".for" do
let :attributes do
{