Sha256: 7b2a50f9d3a04c975d9e827f8c16732cd6a0cde56889f532cfaadef5564f4df5

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

require 'helper'

class RequestApp
  include Newark

  get '/uri' do
    request.uri.to_s
  end

  get '/headers' do
    request.headers['X-Fu']
  end

  post '/body' do
    request.body
  end
end

class TestRequest < Minitest::Unit::TestCase

  include Rack::Test::Methods

  def app
    RequestApp.new
  end

  def test_uri
    get '/uri', { fu: 'bar' }
    assert_equal 'http://example.org/uri?fu=bar', last_response.body
  end

  def test_headers
    get '/headers', {}, { 'HTTP_X_FU' => 'Bar' }
    assert_equal 'Bar', last_response.body
  end

  def test_body
    post '/body', {}, { 'rack.input' => StringIO.new('fubar') }
    assert_equal 'fubar', last_response.body
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newark-0.0.5 test/test_request.rb