Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (39 sloc) 1.467 kb
c00a25e Ryan Tomayko Test framework refactoring
rtomayko authored
1 require File.dirname(__FILE__) + '/helper'
a05d1fa Konstantin Haase require stringio in request_test, fixes GH #51
rkh authored
2 require 'stringio'
a734cf3 Ryan Tomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
3
ff0d068 Simon Rozet Use contest instead of test/spec/mini
sr authored
4 class RequestTest < Test::Unit::TestCase
a734cf3 Ryan Tomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
5 it 'responds to #user_agent' do
6 request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
72a6e01 Ryan Tomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
7 assert request.respond_to?(:user_agent)
8 assert_equal 'Test', request.user_agent
a734cf3 Ryan Tomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
9 end
4a75d9e Ryan Tomayko Fix Request#params on PUT requests [#72]
rtomayko authored
10
11 it 'parses POST params when Content-Type is form-dataish' do
12 request = Sinatra::Request.new(
13 'REQUEST_METHOD' => 'PUT',
14 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
15 'rack.input' => StringIO.new('foo=bar')
16 )
17 assert_equal 'bar', request.params['foo']
18 end
0f030b6 Adam Wiggins request.secure? to check for ssl encrypted connection
adamwiggins authored
19
20 it 'is secure when the url scheme is https' do
21 request = Sinatra::Request.new('rack.url_scheme' => 'https')
22 assert request.secure?
23 end
24
25 it 'is not secure when the url scheme is http' do
26 request = Sinatra::Request.new('rack.url_scheme' => 'http')
27 assert !request.secure?
28 end
29
30 it 'respects X-Forwarded-Proto header for proxied SSL' do
31 request = Sinatra::Request.new('HTTP_X_FORWARDED_PROTO' => 'https')
32 assert request.secure?
33 end
38ad411 Konstantin Haase spec checking wether Marshal.dump(params) is possible
rkh authored
34
35 it 'is possible to marshal params' do
36 request = Sinatra::Request.new(
37 'REQUEST_METHOD' => 'PUT',
38 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
39 'rack.input' => StringIO.new('foo=bar')
40 )
41 params = Sinatra::Base.new.send(:indifferent_hash).replace(request.params)
42 dumped = Marshal.dump(request.params)
43 assert_equal 'bar', Marshal.load(dumped)['foo']
44 end
a734cf3 Ryan Tomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
45 end
Something went wrong with that request. Please try again.