Skip to content

Commit

Permalink
Add support for content as first argument for SubtitleComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotoral committed Feb 7, 2024
1 parent 1d37d34 commit 7b9a0ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/components/bulma/subtitle_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions spec/components/bulma/subtitle_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7b9a0ba

Please sign in to comment.