Sha256: f4a47933482b6be1474e2e95b88f300eb63a68b6df9f2fd4de70c652d11a6b9d

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module Mirage
  class Server < Sinatra::Base
    %w(get post delete put options).each do |http_method|
      send(http_method, '/responses/*') do |name|
        body, query_string = Rack::Utils.unescape(request.body.read.to_s), request.query_string

        options = {:body => body,
                   :http_method => http_method,
                   :endpoint => name,
                   :params => request.params,
                   :headers => extract_http_headers(env)}
        begin
          record = MockResponse.find(options)
        rescue ServerResponseNotFound
          record = MockResponse.find_default(options)
        end

        synchronize do
          tracked_requests(record.response_id) << request.dup
        end


        send_response(record, body, request, query_string)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mirage-4.0.0.alpha1 server/routes/responses.rb