Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi_rspec/string.rb

Instance Method Summary collapse

Instance Method Details

#here_with_pipe!(delimeter = ' ') ⇒ String

Helper for the heredoc functionality. Allows pipe ‘|’ delimeted heredocs with a parameterized delimeter.

Example: html = <<-stop.here_with_pipe(delimeter=“n”)

|<!-- Begin: comment  -->
|<script type="text/javascript">

stop html == ‘<!– Begin: comment –>n<script type=“text/javascript”>’

Parameters:

  • delimeter (String) (defaults to: ' ')

    Joins the lines of strings with this delimeter.

Returns:

  • (String)

    Returns the concatenated string.



16
17
18
19
20
21
# File 'lib/jsonapi_rspec/string.rb', line 16

def here_with_pipe!(delimeter = ' ')
  lines = split("\n")
  lines.map! { |c| c.sub!(/\s*\|/, '') }
  new_string = lines.join(delimeter)
  replace(new_string)
end