class Shoulda::Matchers::Line

def wrap_line(line, direction: :left)

def wrap_line(line, direction: :left)
  index = nil
  if line.length > TERMINAL_WIDTH
    index = determine_where_to_break_line(line, direction: :left)
    if index == -1
      index = determine_where_to_break_line(line, direction: :right)
    end
  end
  if index.nil? || index == -1
    fitted_line = line
    leftover = ''
  else
    fitted_line = line[0..index].rstrip
    leftover = line[index + 1 .. -1]
  end
  { fitted_line: fitted_line, leftover: leftover }
end