test/test_helper.rb
#
# a really bad httpbingo.org for webmock
#
a really bad httpbingo.org for webmock
a really bad httpbingo . org for webmock
def httpbingo(request)
      case request.uri.path
      when %r{/redirect/(\d+)}
        n = Regexp.last_match(1).to_i
        location = n > 1 ? "/redirect/#{n - 1}" : '/get'
        return { status: 302, headers: { Location: location } }
      when '/html'
        return { body: <<~EOF }
          <body>
            <h1>Herman Melville - Moby-Dick</h1>
          </body>
        EOF
      when '/xml'
        return { body: <<~EOF }
          <!--   A SAMPLE set of slides   -->
          <slideshow>
            <slide type="all">
              <title>Wake up to WonderWidgets!</title>
            </slide>
            <slide type="all">
              <title>Overview</title>
            </slide>
          </slideshow>
        EOF
      end
      body = {}.tap do |h|
        if q = request.uri.query
          h[:args] = CGI.parse(q).map { [_1, _2.join(',')] }.to_h
        end
        h[:body] = request.body
        h[:headers] = request.headers
        h[:method] = request.method
        h[:rand] = rand 
      end.compact
      { body: JSON.pretty_generate(body) }
    end
def httpbingo ( request ) case request . uri . path when %r{ /redirect/( \d +) } n = Regexp . last_match ( 1 ) . to_i location = n > 1 ? "/redirect/#{n - 1}" : '/get' return { status : 302 , headers : { Location : location } } when '/html' return { body : <<~EOF } 
          <body>
            <h1>Herman Melville - Moby-Dick</h1>
          </body>
         EOF when '/xml' return { body : <<~EOF } 
          <!--   A SAMPLE set of slides   -->
          <slideshow>
            <slide type="all">
              <title>Wake up to WonderWidgets!</title>
            </slide>
            <slide type="all">
              <title>Overview</title>
            </slide>
          </slideshow>
         EOF end body = { } . tap do | h | if q = request . uri . query h [ :args ] = CGI . parse ( q ) . map { [ _1 , _2 . join ( ',' ) ] } . to_h end h [ :body ] = request . body h [ :headers ] = request . headers h [ :method ] = request . method h [ :rand ] = rand end . compact { body : JSON . pretty_generate ( body ) } end
a really bad httpbingo.org for webmock
a really bad httpbingo . org for webmock
# support for /redirect/:n # otherwise just echo # helpful for testing caching
request
<not_specific>