Module: TurboRspec::Helpers
- Defined in:
- lib/turbo_rspec/helpers.rb
Overview
Factory helpers for building Turbo HTML strings inline in tests. Auto-included into +type: :request+ and +type: :controller+ example groups.
Instance Method Summary collapse
-
#turbo_frame_html(id:, content: nil) ⇒ String
Builds a +
+ HTML string for use in test assertions. -
#turbo_stream_html(action:, target: nil, targets: nil, content: nil) ⇒ String
Builds a +
+ HTML string for use in test assertions.
Instance Method Details
#turbo_frame_html(id:, content: nil) ⇒ String
Builds a +
34 35 36 |
# File 'lib/turbo_rspec/helpers.rb', line 34 def turbo_frame_html(id:, content: nil) "<turbo-frame id=\"#{id}\">#{content}</turbo-frame>" end |
#turbo_stream_html(action:, target: nil, targets: nil, content: nil) ⇒ String
Builds a +
18 19 20 21 22 23 24 |
# File 'lib/turbo_rspec/helpers.rb', line 18 def turbo_stream_html(action:, target: nil, targets: nil, content: nil) attrs = "action=\"#{action}\"" attrs += " target=\"#{target}\"" if target attrs += " targets=\"#{targets}\"" if targets inner = content ? "<template>#{content}</template>" : "<template></template>" "<turbo-stream #{attrs}>#{inner}</turbo-stream>" end |