sinatra-sinatra 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/CHANGES +1 -1
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -20
  4. data/lib/sinatra.rb +0 -1
  5. data/lib/sinatra/base.rb +4 -27
  6. data/sinatra.gemspec +4 -45
  7. data/test/server_test.rb +14 -10
  8. data/test/templates_test.rb +22 -0
  9. data/test/views/foo/hello.test +1 -0
  10. metadata +4 -46
  11. data/compat/app_test.rb +0 -282
  12. data/compat/application_test.rb +0 -262
  13. data/compat/builder_test.rb +0 -101
  14. data/compat/compat_test.rb +0 -12
  15. data/compat/custom_error_test.rb +0 -62
  16. data/compat/erb_test.rb +0 -136
  17. data/compat/events_test.rb +0 -78
  18. data/compat/filter_test.rb +0 -30
  19. data/compat/haml_test.rb +0 -236
  20. data/compat/helper.rb +0 -33
  21. data/compat/mapped_error_test.rb +0 -72
  22. data/compat/pipeline_test.rb +0 -45
  23. data/compat/public/foo.xml +0 -1
  24. data/compat/sass_test.rb +0 -67
  25. data/compat/sessions_test.rb +0 -42
  26. data/compat/streaming_test.rb +0 -133
  27. data/compat/sym_params_test.rb +0 -19
  28. data/compat/template_test.rb +0 -30
  29. data/compat/use_in_file_templates_test.rb +0 -47
  30. data/compat/views/foo.builder +0 -1
  31. data/compat/views/foo.erb +0 -1
  32. data/compat/views/foo.haml +0 -1
  33. data/compat/views/foo.sass +0 -2
  34. data/compat/views/foo_layout.erb +0 -2
  35. data/compat/views/foo_layout.haml +0 -2
  36. data/compat/views/layout_test/foo.builder +0 -1
  37. data/compat/views/layout_test/foo.erb +0 -1
  38. data/compat/views/layout_test/foo.haml +0 -1
  39. data/compat/views/layout_test/foo.sass +0 -2
  40. data/compat/views/layout_test/layout.builder +0 -3
  41. data/compat/views/layout_test/layout.erb +0 -1
  42. data/compat/views/layout_test/layout.haml +0 -1
  43. data/compat/views/layout_test/layout.sass +0 -2
  44. data/compat/views/no_layout/no_layout.builder +0 -1
  45. data/compat/views/no_layout/no_layout.haml +0 -1
  46. data/lib/sinatra/compat.rb +0 -266
  47. data/lib/sinatra/test.rb +0 -128
  48. data/lib/sinatra/test/bacon.rb +0 -19
  49. data/lib/sinatra/test/rspec.rb +0 -13
  50. data/lib/sinatra/test/spec.rb +0 -11
  51. data/lib/sinatra/test/unit.rb +0 -13
  52. data/test/test_test.rb +0 -152
@@ -1,13 +0,0 @@
1
- require 'sinatra/test'
2
- require 'test/unit'
3
-
4
- Sinatra::Test.deprecate('test/unit')
5
-
6
- Test::Unit::TestCase.send :include, Sinatra::Test
7
-
8
- Sinatra::Default.set(
9
- :environment => :test,
10
- :run => false,
11
- :raise_errors => true,
12
- :logging => false
13
- )
data/test/test_test.rb DELETED
@@ -1,152 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- require 'yaml'
4
-
5
- # silence deprecation warning when requiring sinatra/test
6
- $VERBOSE, v = nil, $VERBOSE
7
- require 'sinatra/test'
8
- $VERBOSE = v
9
-
10
- class TestTest < Test::Unit::TestCase
11
- include Sinatra::Test
12
-
13
- def request
14
- YAML.load(body)
15
- end
16
-
17
- def request_body
18
- request['test.body']
19
- end
20
-
21
- def request_params
22
- YAML.load(request['test.params'])
23
- end
24
-
25
- setup do
26
- mock_app {
27
- %w[get head post put delete].each { |verb|
28
- send(verb, '/') do
29
- redirect '/redirected' if params[:redirect]
30
- env.update('test.body' => request.body.read)
31
- env.update('test.params' => params.to_yaml)
32
- env.to_yaml
33
- end
34
- }
35
-
36
- get '/redirected' do
37
- "you've been redirected"
38
- end
39
- }
40
- end
41
-
42
- it 'allows GET/HEAD/POST/PUT/DELETE' do
43
- get '/'
44
- assert_equal('GET', request['REQUEST_METHOD'])
45
-
46
- post '/'
47
- assert_equal('POST', request['REQUEST_METHOD'])
48
-
49
- put '/'
50
- assert_equal('PUT', request['REQUEST_METHOD'])
51
-
52
- delete '/'
53
- assert_equal('DELETE', request['REQUEST_METHOD'])
54
-
55
- head '/'
56
- assert response.headers['Content-Length'].to_i > 0
57
- assert_equal('', body)
58
- end
59
-
60
- it 'allows to specify a body' do
61
- post '/', '42'
62
- assert_equal '42', request_body
63
- end
64
-
65
- it 'allows to specify params' do
66
- get '/', :foo => 'bar'
67
- assert_equal 'bar', request_params['foo']
68
- end
69
-
70
- it 'supports nested params' do
71
- get '/', :foo => { :x => 'y', :chunky => 'bacon' }
72
- assert_equal "y", request_params['foo']['x']
73
- assert_equal "bacon", request_params['foo']['chunky']
74
- end
75
-
76
- it 'provides easy access to response status and body' do
77
- get '/'
78
- assert_equal 200, status
79
- assert body =~ /^---/
80
- end
81
-
82
- it 'delegates methods to @response' do
83
- get '/'
84
- assert ok?
85
- end
86
-
87
- it 'follows redirect' do
88
- get '/', :redirect => true
89
- follow!
90
- assert_equal "you've been redirected", body
91
- end
92
-
93
- it 'provides sugar for common HTTP headers' do
94
- get '/', :env => { :accept => 'text/plain' }
95
- assert_equal 'text/plain', request['HTTP_ACCEPT']
96
-
97
- get '/', :env => { :agent => 'TATFT' }
98
- assert_equal 'TATFT', request['HTTP_USER_AGENT']
99
-
100
- get '/', :env => { :host => '1.2.3.4' }
101
- assert_equal '1.2.3.4', request['HTTP_HOST']
102
-
103
- get '/', :env => { :session => {'foo' => 'bar'} }
104
- assert_equal({'foo' => 'bar'}, request['rack.session'])
105
-
106
- get '/', :env => { :cookies => 'foo' }
107
- assert_equal 'foo', request['HTTP_COOKIE']
108
-
109
- get '/', :env => { :content_type => 'text/plain' }
110
- assert_equal 'text/plain', request['CONTENT_TYPE']
111
- end
112
-
113
- it 'allow to test session easily' do
114
- app = mock_app(Sinatra::Default) {
115
- get '/' do
116
- session['foo'] = 'bar'
117
- 200
118
- end
119
-
120
- post '/' do
121
- assert_equal 'bar', session['foo']
122
- session['foo'] || "blah"
123
- end
124
- }
125
-
126
- browser = Sinatra::TestHarness.new(app)
127
- browser.get '/'
128
- browser.post '/', {}, :session => { 'foo' => 'bar' }
129
- assert_equal 'bar', browser.response.body
130
- end
131
-
132
- it 'yields the request object to the block before invoking the application' do
133
- called = false
134
- get '/' do |req|
135
- called = true
136
- assert req.kind_of?(Rack::MockRequest)
137
- end
138
- assert called
139
- end
140
-
141
- it 'sets the environment to :test on include' do
142
- Sinatra::Default.set(:environment, :production)
143
- Class.new { include Sinatra::Test }
144
- assert_equal :test, Sinatra::Default.environment
145
- end
146
-
147
- def test_TestHarness
148
- session = Sinatra::TestHarness.new(@app)
149
- response = session.get('/')
150
- assert_equal 200, response.status
151
- end
152
- end