Skip to content

Instantly share code, notes, and snippets.

@bensheldon
Created November 11, 2025 16:38
Show Gist options
  • Select an option

  • Save bensheldon/0561c298e22383c0ebb3a12baa4fa138 to your computer and use it in GitHub Desktop.

Select an option

Save bensheldon/0561c298e22383c0ebb3a12baa4fa138 to your computer and use it in GitHub Desktop.
# 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