To have indented content as well as an indented closing identifier, you can use a “squiggly” heredoc, which uses a “~” instead of a “-” after <<:
expected_result = <<~SQUIGGLY_HEREDOC
This would contain specially formatted text.
That might span many lines
SQUIGGLY_HEREDOC
The indentation of the least-indented line will be removed from each line of the content. Note that empty lines and lines consisting solely of literal tabs and spaces will be ignored for the purposes of determining indentation, but escaped tabs and spaces are considered non-indentation characters.
3
u/rfdonnelly Dec 26 '15
The best addition didn't make it to the announcement.
From: https://github.com/ruby/ruby/blob/v2_3_0/NEWS
From: https://github.com/ruby/ruby/blob/v2_3_0/doc/syntax/literals.rdoc