diff --git a/app/components/bulma/subtitle_component.rb b/app/components/bulma/subtitle_component.rb index 0b97961..37bb6f3 100644 --- a/app/components/bulma/subtitle_component.rb +++ b/app/components/bulma/subtitle_component.rb @@ -2,8 +2,12 @@ module Bulma class SubtitleComponent < Component + def initialize(text = nil) + @text = text + end + def call - content_tag :p, nil, class: "subtitle" + content_tag :p, @text, class: "subtitle" end end end diff --git a/spec/components/bulma/subtitle_component_spec.rb b/spec/components/bulma/subtitle_component_spec.rb index 0186af0..db189a4 100644 --- a/spec/components/bulma/subtitle_component_spec.rb +++ b/spec/components/bulma/subtitle_component_spec.rb @@ -6,4 +6,10 @@ expect(page).to have_css "p.subtitle" end + + it "renders content provided as first argument" do + render_inline(described_class.new("Subtitle")) + + expect(page).to have_content "Subtitle" + end end