Created
November 11, 2025 16:38
-
-
Save bensheldon/0561c298e22383c0ebb3a12baa4fa138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| gem "rails" | |
| end | |
| require "active_support" | |
| require "active_support/core_ext/object/blank" | |
| require "minitest/autorun" | |
| require "erb" | |
| class MarkdownTest < ActiveSupport::TestCase | |
| def test_stuff | |
| fruits = [ | |
| "apple", | |
| "banana", | |
| ["citrus", ["orange", "lemon - this is a multiline string\n\nSome more lemon content."]], | |
| ] | |
| some_erb = <<~ERB | |
| <% fruits.each do |fruit| %> | |
| <% if fruit.is_a?(Array) %> | |
| <% fruit, subfruits = fruit %> | |
| - <%= fruit %> | |
| <% subfruits.each do |subfruit| %> | |
| - <%= subfruit %> | |
| <% end %> | |
| <% else %> | |
| - <%= fruit %> | |
| <% end %> | |
| <% end %> | |
| ERB | |
| template = ERB.new(some_erb, trim_mode: "-") | |
| output = template.result(binding) | |
| assert_equal(<<~ERB, output) | |
| - apple | |
| - banana | |
| - citrus | |
| - orange | |
| - lemon - this is a multiline string. | |
| Some more lemon content. | |
| ERB | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment