def insert_text(position, pattern, new_text)
        index = case pattern
          when Regexp
            if match = @controller.response.body.match(pattern)
              match.offset(0)[position == :before ? 0 : 1]
            else
              @controller.response.body.size
            end
          else
            pattern
          end
        newbody = @controller.response.body
        newbody.insert index, new_text
        @controller.response.body = newbody
      end
def insert_text(position, pattern, new_text)
        index = case pattern
          when Regexp
            if match = @controller.response.body.match(pattern)
              match.offset(0)[position == :before ? 0 : 1]
            else
              @controller.response.body.size
            end
          else
            pattern
          end
        newbody = @controller.response.body
        newbody.insert index, new_text
        @controller.response.body = newbody
      end
Inserts text in to the body of the document
 +pattern+ is a Regular expression which, when matched, will cause +new_text+
 to be inserted before or after the match.  If no match is found, +new_text+ is appended
 to the body instead. +position+ may be either :before or :after