Sha256: e0e25f6178df3158a1f416e4ae153e79bac025a23fe402a534ba7ecd95a8f79c

Contents?: true

Size: 877 Bytes

Versions: 9

Compression:

Stored size: 877 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'helpers/template_requirements'
require 'helpers/http_headers'

module Mirage
  class Server < Sinatra::Base
    helpers do

      def synchronize &block
        Mutex.new.synchronize &block
      end

      def response_id
        params[:id].to_i
      end

      def prime &block
        block.call Mirage::Client.new "http://localhost:#{settings.port}"
      end

      def send_response(mock_response, body='', request={}, query_string='')
        sleep mock_response.response_spec['delay']
        content_type(mock_response.response_spec['content_type'])
        status mock_response.response_spec['status']
        headers mock_response.headers
        mock_response.value(body, request, query_string)
      end

      def tracked_requests response_id
        REQUESTS[response_id] ||= []
      end


    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mirage-4.0.0.alpha10 server/helpers.rb
mirage-4.0.0.alpha9 server/helpers.rb
mirage-4.0.0.alpha8 server/helpers.rb
mirage-4.0.0.alpha6 server/helpers.rb
mirage-4.0.0.alpha5 server/helpers.rb
mirage-4.0.0.alpha4 server/helpers.rb
mirage-4.0.0.alpha3 server/helpers.rb
mirage-4.0.0.alpha2 server/helpers.rb
mirage-4.0.0.alpha1 server/helpers.rb