mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
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:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user