Sha256: a590892dad80213e71a7049340348dd74aff1389286081542f16205270ed7c5f

Contents?: true

Size: 585 Bytes

Versions: 8

Compression:

Stored size: 585 Bytes

Contents

require 'sinatra/base'

class HttpTestServer < Sinatra::Base
  get "/method" do
    text 200, "GET"
  end

  post "/method" do
    text 200, "POST"
  end

  get "/status/:response_status" do
    if params[:response_status] =~ /\A\d+\z/
      status = params[:response_status]
      message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || "Unknown"
      text status.to_i, "#{status} #{message}"
    else
      text 500, "Invalid Status"
    end
  end

  def text(response_code, body, headers ={})
    [response_code, { "Content-Type" => "text/plain" }.merge(headers), body]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
litmus_paper-0.3.2 spec/support/http_test_server.rb
litmus_paper-0.3.1 spec/support/http_test_server.rb
litmus_paper-0.3.0 spec/support/http_test_server.rb
litmus_paper-0.2.2 spec/support/http_test_server.rb
litmus_paper-0.2.1 spec/support/http_test_server.rb
litmus_paper-0.2.0 spec/support/http_test_server.rb
litmus_paper-0.1.0 spec/support/http_test_server.rb
litmus_paper-0.0.3 spec/support/http_test_server.rb