# frozen_string_literal: true require_relative "../test_helper" module Parser class ERBContextMismatchTest < Minitest::Spec include SnapshotUtils # https://github.com/marcoroth/herb/issues/701 test "out of order closing tags across ERB blocks" do assert_parsed_snapshot(<<~ERB)
<%= render CardComponent.new do |card| %>
<% end %>
ERB end # https://github.com/marcoroth/herb/issues/398 test "conditionally opening tag then closing unconditionally" do assert_parsed_snapshot(<<~ERB) <% if some_condition %>
<% else %>
<% end %> Content
ERB end # https://github.com/marcoroth/herb/issues/399 test "opening and closing tag in different if blocks" do assert_parsed_snapshot(<<~ERB) <% if wrap_in_dialog? %> <% end %>
Stuff
<% if wrap_in_dialog? %>
<% end %> ERB end # https://github.com/marcoroth/herb/issues/490 test "tag opened in elsif closed outside conditional" do assert_parsed_snapshot(<<~ERB) ERB end # https://github.com/marcoroth/herb/issues/83 test "element opened in block must be closed within block" do assert_parsed_snapshot(<<~ERB) <% if true %>

123 <% end %>

ERB end # https://github.com/marcoroth/herb/issues/84 test "opening in one context and closing in another context" do assert_parsed_snapshot(<<~ERB) <% if true %>

<% end %> Content <% if true %>

<% end %> ERB end test "stray closing tag without opening" do assert_parsed_snapshot(<<~ERB)
content
ERB end test "unclosed tag without closing" do assert_parsed_snapshot(<<~ERB)
content
ERB end end end