From d20d35a6d9e4c4fa4511f5a9d6fbc1450720f077 Mon Sep 17 00:00:00 2001 From: Diego Toral Date: Wed, 7 Feb 2024 11:25:15 -0800 Subject: [PATCH] Add support for content as block for SubtitleComponent --- app/components/bulma/subtitle_component.rb | 2 +- spec/components/bulma/subtitle_component_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/bulma/subtitle_component.rb b/app/components/bulma/subtitle_component.rb index 37bb6f3..d67aace 100644 --- a/app/components/bulma/subtitle_component.rb +++ b/app/components/bulma/subtitle_component.rb @@ -7,7 +7,7 @@ def initialize(text = nil) end def call - content_tag :p, @text, class: "subtitle" + content_tag :p, @text || content, class: "subtitle" end end end diff --git a/spec/components/bulma/subtitle_component_spec.rb b/spec/components/bulma/subtitle_component_spec.rb index db189a4..bab57ef 100644 --- a/spec/components/bulma/subtitle_component_spec.rb +++ b/spec/components/bulma/subtitle_component_spec.rb @@ -12,4 +12,10 @@ expect(page).to have_content "Subtitle" end + + it "render content provided as a block" do + render_inline(described_class.new) { "Subtitle" } + + expect(page).to have_content "Subtitle" + end end