bmizerany-sinatra 0.9.0 → 0.9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/AUTHORS ADDED
@@ -0,0 +1,40 @@
1
+ Sinatra was designed and developed by Blake Mizerany (bmizerany) in
2
+ California. Continued development would not be possible without the ongoing
3
+ financial support provided by Heroku <heroku.com> and the emotional support
4
+ provided by Adam Wiggins (adamwiggins), Chris Wanstrath (defunkt), PJ Hyett (pjhyett), and
5
+ the rest of the Github crew.
6
+
7
+ Special thanks to the following extraordinary individuals, who-out which
8
+ Sinatra would not be possible:
9
+
10
+ * Ryan Tomayko (rtomayko) for constantly fixing whitespace errors 60d5006
11
+ * Ezra Zygmuntowicz (ezmobius) for initial help and letting Blake steal
12
+ some of merbs internal code.
13
+ * Christopher Schneid (cschneid) for The Book, the blog (gittr.com),
14
+ irclogger.com, and a bunch of useful patches.
15
+ * Markus Prinz (cypher) for patches over the years, caring about
16
+ the README, and hanging in there when times were rough.
17
+ * Simon Rozet (sr) for a ton of doc patches, HAML options, and all that
18
+ advocacy stuff he's going to do for 1.0.
19
+ * Erik Kastner (kastner) for fixing MIME_TYPES under Rack 0.5.
20
+ * Ben Bleything (bleything) for caring about HTTP status codes and doc fixes.
21
+ * Igal Koshevoy (igal) for root path detection under Thin/Passenger.
22
+ * Jon Crosby (jcrosby) for coffee breaks, doc fixes, and just because, man.
23
+ * Karel Minarik (karmi) for screaming until the website came back up.
24
+ * Jeremy Evans (jeremyevans) for unbreaking optional path params (twice!)
25
+ * The GitHub guys for stealing Blake's table.
26
+ * Nickolas Means (nmeans) for Sass template support.
27
+ * Victor Hugo Borja (vic) for splat'n routes specs and doco.
28
+ * Avdi Grimm (avdi) for basic RSpec support.
29
+ * Jack Danger Canty for a more accurate root directory and for making me
30
+ watch this just now: http://www.youtube.com/watch?v=ueaHLHgskkw.
31
+ * Mathew Walker for making escaped paths work with static files.
32
+ * Millions of Us for having the problem that led to Sinatra's conception.
33
+ * Songbird for the problems that helped Sinatra's future become realized.
34
+ * Rick Olsen (technoweenie) for the killer plug at RailsConf '08.
35
+ * Steven Garcia for the amazing custom artwork you see on 404's and 500's
36
+
37
+ and last but not least:
38
+
39
+ * Frank Sinatra (chairman of the board) for having so much class he
40
+ deserves a web-framework named after him.
data/CHANGES CHANGED
@@ -1,27 +1,41 @@
1
- = 0.9.0 (unreleased)
1
+ = 0.9.0 / 2009-01-18
2
2
 
3
- * New ":provides" route condition takes an array of mime types and
4
- matches only when an Accept request header is present with a
5
- corresponding type. [cypher]
3
+ * Works with and requires Rack >= 0.9.1
4
+
5
+ * Multiple Sinatra applications can now co-exist peacefully within a
6
+ single process. The new "Sinatra::Base" class can be subclassed to
7
+ establish a blank-slate Rack application or middleware component.
8
+ Documentation on using these features is forth-coming; the following
9
+ provides the basic gist: http://gist.github.com/38605
6
10
 
7
- * Work with and require Rack >= 0.9
11
+ * Parameters with subscripts are now parsed into a nested/recursive
12
+ Hash structure. e.g., "post[title]=Hello&post[body]=World" yields
13
+ params: {'post' => {'title' => 'Hello', 'body' => 'World'}}.
8
14
 
9
15
  * Regular expressions may now be used in route pattens; captures are
10
16
  available at "params[:captures]".
11
17
 
18
+ * New ":provides" route condition takes an array of mime types and
19
+ matches only when an Accept request header is present with a
20
+ corresponding type. [cypher]
21
+
22
+ * New request-level "pass" method; immediately exits the current block
23
+ and passes control to the next matching route.
24
+
12
25
  * The request-level "body" method now takes a block; evaluation is
13
26
  deferred until an attempt is made to read the body. The block must
14
27
  return a String or Array.
15
28
 
16
- * Better default "app_file", "root", "public", and "views" location
17
- detection; changes to "root" and "app_file" automatically cascade to
18
- other options that depend on them.
19
-
20
29
  * New "route conditions" system for attaching rules for when a route
21
30
  matches. The :agent and :host route options now use this system.
22
31
 
23
- * New request-level "pass" method; immediately exits the current block
24
- and passes control to the next matching route.
32
+ * New "dump_errors" option controls whether the backtrace is dumped to
33
+ rack.errors when an exception is raised from a route. The option is
34
+ enabled by default for top-level apps.
35
+
36
+ * Better default "app_file", "root", "public", and "views" location
37
+ detection; changes to "root" and "app_file" automatically cascade to
38
+ other options that depend on them.
25
39
 
26
40
  * Error mappings are now split into two distinct layers: exception
27
41
  mappings and custom error pages. Exception mappings are registered
@@ -31,6 +45,20 @@
31
45
  has the status code specified. It's also possible to register an error
32
46
  page for a range of status codes: "error(500..599)".
33
47
 
48
+ * In-file templates are now automatically imported from the file that
49
+ requires 'sinatra'. The use_in_file_templates! method is still available
50
+ for loading templates from other files.
51
+
52
+ * Sinatra's testing support is no longer dependent on Test::Unit. Requiring
53
+ 'sinatra/test' adds the Sinatra::Test module and Sinatra::TestHarness
54
+ class, which can be used with any test framework. The 'sinatra/test/unit',
55
+ 'sinatra/test/spec', 'sinatra/test/rspec', or 'sinatra/test/bacon' files
56
+ can be required to setup a framework-specific testing environment. See the
57
+ README for more information.
58
+
59
+ * Added support for Bacon (test framework). The 'sinatra/test/bacon' file
60
+ can be required to setup Sinatra test helpers on Bacon::Context.
61
+
34
62
  * Deprecated "set_option" and "set_options"; use "set" instead.
35
63
 
36
64
  * Deprecated the "env" option ("options.env"); use "environment" instead.
@@ -55,6 +83,10 @@
55
83
  treated as internal server errors and result in a 500 response
56
84
  status.
57
85
 
86
+ * Deprecated the "get_it", "post_it", "put_it", "delete_it", and "head_it"
87
+ test helper methods. Use "get", "post", "put", "delete", and "head",
88
+ respectively, instead.
89
+
58
90
  * Removed Event and EventContext classes. Applications are defined in a
59
91
  subclass of Sinatra::Base; each request is processed within an
60
92
  instance.
data/README.rdoc CHANGED
@@ -1,9 +1,7 @@
1
1
  = Sinatra
2
2
 
3
3
  Sinatra is a DSL for quickly creating web-applications in Ruby with minimal
4
- effort.
5
-
6
- == Sample App
4
+ effort:
7
5
 
8
6
  # myapp.rb
9
7
  require 'rubygems'
@@ -32,10 +30,6 @@ Run with <tt>ruby myapp.rb</tt> and view at <tt>http://localhost:4567</tt>
32
30
  .. annihilate something ..
33
31
  end
34
32
 
35
- head '/' do
36
-
37
- end
38
-
39
33
  == Routes
40
34
 
41
35
  Routes are matched based on the order of declaration. The first route that
@@ -47,14 +41,17 @@ Basic routes:
47
41
  ...
48
42
  end
49
43
 
50
- Named parameters:
44
+ Route patterns may include named parameters, accessible via the
45
+ <tt>params</tt> hash:
51
46
 
52
47
  get '/:name' do
53
48
  # matches "GET /foo" and "GET /bar"
54
49
  # params[:name] is 'foo' or 'bar'
50
+ "Hello #{params[:name]}!"
55
51
  end
56
52
 
57
- Splat parameters:
53
+ Route patterns may also include splat (or wildcard) parameters, accessible
54
+ via the <tt>params[:splat]</tt> array.
58
55
 
59
56
  get '/say/*/to/*' do
60
57
  # matches /say/hello/to/world
@@ -66,7 +63,13 @@ Splat parameters:
66
63
  params[:splat] # => ["path/to/file", "xml"]
67
64
  end
68
65
 
69
- User agent matching:
66
+ Route matching with Regular Expressions:
67
+
68
+ get %r{/hello/([\w]+)} do
69
+ "Hello, #{params[:captures].first}!"
70
+ end
71
+
72
+ Routes may include a variety of matching conditions, such as the user agent:
70
73
 
71
74
  get '/foo', :agent => /Songbird (\d\.\d)[\d\/]*?/ do
72
75
  "You're using Songbird version #{params[:agent][0]}"
@@ -78,33 +81,29 @@ User agent matching:
78
81
 
79
82
  == Static Files
80
83
 
81
- Put all of your static content in the ./public directory
82
-
83
- root
84
- \ public
85
-
86
- To use a different static directory:
84
+ Static files are served from the <tt>./public</tt> directory. You can specify
85
+ a different location by setting the <tt>:public</tt> option:
87
86
 
88
87
  set :public, File.dirname(__FILE__) + '/static'
89
88
 
90
- == Views
91
-
92
- Views are searched for in a ./views directory in the same location as
93
- your main application.
89
+ == Views / Templates
94
90
 
95
- To use a different views directory:
91
+ Templates are assumed to be located directly under a <tt>./views</tt>
92
+ directory. To use a different views directory:
96
93
 
97
94
  set :views, File.dirname(__FILE__) + '/templates'
98
95
 
99
96
  === Haml Templates
100
97
 
98
+ The haml gem/library is required to render HAML templates:
99
+
101
100
  get '/' do
102
101
  haml :index
103
102
  end
104
103
 
105
104
  Renders <tt>./views/index.haml</tt>.
106
105
 
107
- === Erb
106
+ === Erb Templates
108
107
 
109
108
  get '/' do
110
109
  erb :index
@@ -112,11 +111,20 @@ Renders <tt>./views/index.haml</tt>.
112
111
 
113
112
  Renders <tt>./views/index.erb</tt>
114
113
 
115
- === Builder
114
+ === Builder Templates
116
115
 
117
- See Sinatra::Builder
116
+ The builder gem/library is required to render builder templates:
118
117
 
119
- === Sass
118
+ get '/' do
119
+ content_type 'application/xml', :charset => 'utf-8'
120
+ builder :index
121
+ end
122
+
123
+ Renders <tt>./views/index.builder</tt>.
124
+
125
+ === Sass Templates
126
+
127
+ The sass gem/library is required to render Sass templates:
120
128
 
121
129
  get '/stylesheet.css' do
122
130
  content_type 'text/css', :charset => 'utf-8'
@@ -135,9 +143,8 @@ Renders the inlined template string.
135
143
 
136
144
  === Accessing Variables
137
145
 
138
- Templates are evaluated within the Sinatra::EventContext instance
139
- used to evaluate event blocks. Instance variables set in event
140
- blocks can be accessed direcly in views:
146
+ Templates are evaluated within the same context as the route blocks. Instance
147
+ variables set in route blocks are available in templates:
141
148
 
142
149
  get '/:id' do
143
150
  @foo = Foo.find(params[:id])
@@ -158,27 +165,32 @@ other templates.
158
165
 
159
166
  Templates may be defined at the end of the source file:
160
167
 
168
+ require 'rubygems'
169
+ require 'sinatra'
170
+
161
171
  get '/' do
162
172
  haml :index
163
173
  end
164
174
 
165
- use_in_file_templates!
166
-
167
175
  __END__
168
176
 
169
177
  @@ layout
170
- X
171
- = yield
172
- X
178
+ %html
179
+ = yield
173
180
 
174
181
  @@ index
175
182
  %div.title Hello world!!!!!
176
183
 
184
+ NOTE: Sinatra will automaticly load any in-file-templates in the
185
+ source file that first required sinatra. If you have in-file-templates
186
+ in another source file you will need to explicitly call
187
+ +use_in_file_templates! on main in that file.
188
+
177
189
  It's also possible to define named templates using the top-level template
178
190
  method:
179
191
 
180
192
  template :layout do
181
- "X\n=yield\nX"
193
+ "%html\n =yield\n"
182
194
  end
183
195
 
184
196
  template :index do
@@ -189,9 +201,17 @@ method:
189
201
  haml :index
190
202
  end
191
203
 
204
+ If a template named "layout" exists, it will be used each time a template
205
+ is rendered. You can disable layouts by passing <tt>:layout => false</tt>.
206
+
207
+ get '/' do
208
+ haml :index, :layout => !request.xhr?
209
+ end
210
+
192
211
  == Helpers
193
212
 
194
- The top-level <tt>helpers</tt> method
213
+ Use the top-level <tt>helpers</tt> method to define helper methods for use in
214
+ route blocks and templates:
195
215
 
196
216
  helpers do
197
217
  def bar(name)
@@ -205,7 +225,9 @@ The top-level <tt>helpers</tt> method
205
225
 
206
226
  == Filters
207
227
 
208
- Before filters are evaluated in request context before routing is performed:
228
+ Before filters are evaluated before each request within the context of the
229
+ request and can modify the request and response. Instance variables set in
230
+ filters are accessible by routes and templates.
209
231
 
210
232
  before do
211
233
  @note = 'Hi!'
@@ -217,64 +239,75 @@ Before filters are evaluated in request context before routing is performed:
217
239
  params[:splat] #=> 'bar/baz'
218
240
  end
219
241
 
220
- Before filters can modify the request and response; instance variables are
221
- available to routes.
242
+ == Halting
222
243
 
223
- == Halt!
244
+ To immediately stop a request during a before filter or route use:
224
245
 
225
- To immediately stop a request during a before filter or event use:
246
+ halt
226
247
 
227
- throw :halt
248
+ You can also specify a body when halting ...
228
249
 
229
- Set the body to a simple string
250
+ halt 'this will be the body'
230
251
 
231
- throw :halt, 'this will be the body'
252
+ Set the status and body ...
232
253
 
233
- Set status then the body
254
+ halt 401, 'go away!'
234
255
 
235
- throw :halt, [401, 'go away!']
256
+ == Passing
236
257
 
237
- Run a proc inside the Sinatra::EventContext instance and set the body to the
238
- result
258
+ A route can punt processing to the next matching route using the <tt>pass</tt>
259
+ statement:
239
260
 
240
- throw :halt, lambda { puts 'In a proc!'; 'I just wrote to $stdout!' }
261
+ get '/guess/:who' do
262
+ pass unless params[:who] == 'Frank'
263
+ "You got me!"
264
+ end
265
+
266
+ get '/guess/*' do
267
+ "You missed!"
268
+ end
269
+
270
+ The route block is immediately exited and control continues with the next
271
+ matching route. If no matching route is found, a 404 is returned.
241
272
 
242
273
  == Configuration and Reloading
243
274
 
244
275
  Sinatra supports multiple environments and reloading. Reloading happens
245
- before every request when running under the :development environment. Wrap
246
- your configurations in <tt>configure</tt> (i.e. Database connections, Constants,
247
- etc.) to protect them from reloading or to target specific environments.
276
+ before each request when running under the <tt>:development</tt>
277
+ environment. Wrap your configurations (e.g., database connections, constants,
278
+ etc.) in <tt>configure</tt> blocks to protect them from reloading or to
279
+ target specific environments.
248
280
 
249
- All environments:
281
+ Run once, at startup, in any environment:
250
282
 
251
283
  configure do
252
284
  ...
253
285
  end
254
286
 
255
- Production:
287
+ Run only when the environment (RACK_ENV environment variable) is set to
288
+ <tt>:production</tt>.
256
289
 
257
290
  configure :production do
258
291
  ...
259
292
  end
260
293
 
261
- Two at a time:
294
+ Run when the environment (RACK_ENV environment variable) is set to
295
+ either <tt>:production</tt> or <tt>:test</tt>.
262
296
 
263
297
  configure :production, :test do
264
298
  ...
265
299
  end
266
300
 
267
- This is also really nifty for error handling.
268
-
269
301
  == Error handling
270
302
 
271
- Error handlers run inside the current Sinatra::EventContext instance, which
272
- means you get all the goodies it has to offer (i.e. haml, erb, throw :halt,
273
- etc.)
303
+ Error handlers run within the same context as routes and before filters, which
304
+ means you get all the goodies it has to offer, like <tt>haml</tt>, <tt>erb</tt>,
305
+ <tt>halt</tt>, etc.
274
306
 
275
307
  === Not Found
276
308
 
277
- When Sinatra::NotFound is raised, the not_found handler is invoked:
309
+ When a <tt>Sinatra::NotFound</tt> exception is raised, or the response's status
310
+ code is 404, the <tt>not_found</tt> handler is invoked:
278
311
 
279
312
  not_found do
280
313
  'This is nowhere to be found'
@@ -282,14 +315,12 @@ When Sinatra::NotFound is raised, the not_found handler is invoked:
282
315
 
283
316
  === Error
284
317
 
285
- By default, the +error+ handler is invoked on Sinatra::ServerError or when
286
- an unknown error occurs.
287
-
288
- The exception can be obtained from the 'sinatra.error' variable in
289
- request.env.
318
+ The +error+ handler is invoked any time an exception is raised from a route
319
+ block or before filter. The exception object can be obtained from the
320
+ 'sinatra.error' Rack variable:
290
321
 
291
322
  error do
292
- 'Sorry there was a nasty error - ' + request.env['sinatra.error'].name
323
+ 'Sorry there was a nasty error - ' + env['sinatra.error'].name
293
324
  end
294
325
 
295
326
  Custom errors:
@@ -309,12 +340,12 @@ You get this:
309
340
  So what happened was... something bad
310
341
 
311
342
  Sinatra installs special not_found and error handlers when running under
312
- the development.
343
+ the development environment.
313
344
 
314
345
  == Mime types
315
346
 
316
- When using send_file or static files you may have mime types Sinatra doesn't
317
- understand. Use +mime+ in those cases.
347
+ When using <tt>send_file</tt> or static files you may have mime types Sinatra
348
+ doesn't understand. Use +mime+ to register them by file extension:
318
349
 
319
350
  mime :foo, 'text/foo'
320
351
 
@@ -355,59 +386,61 @@ typically don't have to +use+ them explicitly.
355
386
 
356
387
  == Testing
357
388
 
358
- === Test/Unit
389
+ The Sinatra::Test module includes a variety of helper methods for testing
390
+ your Sinatra app. Sinatra includes support for Test::Unit, test-spec, RSpec,
391
+ and Bacon through separate source files.
392
+
393
+ === Test::Unit
359
394
 
360
- require 'rubygems'
361
395
  require 'sinatra'
362
396
  require 'sinatra/test/unit'
363
397
  require 'my_sinatra_app'
364
398
 
365
399
  class MyAppTest < Test::Unit::TestCase
366
-
367
400
  def test_my_default
368
- get_it '/'
401
+ get '/'
369
402
  assert_equal 'My Default Page!', @response.body
370
403
  end
371
404
 
372
405
  def test_with_agent
373
- get_it '/', :agent => 'Songbird'
406
+ get '/', :agent => 'Songbird'
374
407
  assert_equal 'You're in Songbird!', @response.body
375
408
  end
376
409
 
377
410
  ...
378
-
379
411
  end
380
412
 
381
- === Test/Spec
413
+ === Test::Spec
414
+
415
+ Install the test-spec gem and require <tt>'sinatra/test/spec'</tt> before
416
+ your app:
382
417
 
383
- require 'rubygems'
384
418
  require 'sinatra'
385
419
  require 'sinatra/test/spec'
386
420
  require 'my_sinatra_app'
387
421
 
388
422
  describe 'My app' do
389
-
390
423
  it "should show a default page" do
391
- get_it '/'
424
+ get '/'
392
425
  should.be.ok
393
426
  body.should.equal 'My Default Page!'
394
427
  end
395
428
 
396
429
  ...
397
-
398
430
  end
399
431
 
400
432
  === RSpec
401
433
 
402
- require 'rubygems'
403
- require 'spec'
434
+ Install the rspec gem and require <tt>'sinatra/test/rspec'</tt> before
435
+ your app:
436
+
404
437
  require 'sinatra'
405
438
  require 'sinatra/test/rspec'
406
439
  require 'my_sinatra_app'
407
440
 
408
441
  describe 'My app' do
409
442
  it 'should show a default page' do
410
- get_it '/'
443
+ get '/'
411
444
  @response.should be_ok
412
445
  @response.body.should == 'My Default Page!'
413
446
  end
@@ -416,20 +449,35 @@ typically don't have to +use+ them explicitly.
416
449
 
417
450
  end
418
451
 
419
- See Sinatra::Test::Methods for more information on +get_it+, +post_it+,
420
- +put_it+, and friends.
452
+ === Bacon
453
+
454
+ require 'sinatra'
455
+ require 'sinatra/test/bacon'
456
+ require 'my_sinatra_app'
457
+
458
+ describe 'My app' do
459
+ it 'should be ok' do
460
+ get '/'
461
+ should.be.ok
462
+ body.should == 'Im OK'
463
+ end
464
+ end
465
+
466
+ See Sinatra::Test for more information on +get+, +post+, +put+, and
467
+ friends.
421
468
 
422
469
  == Command line
423
470
 
424
471
  Sinatra applications can be run directly:
425
472
 
426
- ruby myapp.rb [-h] [-x] [-p PORT] [-e ENVIRONMENT]
473
+ ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-s HANDLER]
427
474
 
428
475
  Options are:
429
476
 
430
477
  -h # help
431
478
  -p # set the port (default is 4567)
432
479
  -e # set the environment (default is development)
480
+ -s # specify rack server/handler (default is thin)
433
481
  -x # turn on the mutex lock (default is off)
434
482
 
435
483
  == Contributing
@@ -448,7 +496,7 @@ screencasts about Git, which you can find here: http://www.gitcasts.com/
448
496
  === First Time: Cloning The Sinatra Repo
449
497
 
450
498
  cd where/you/keep/your/projects
451
- git clone git://github.com/bmizerany/sinatra.git
499
+ git clone git://github.com/sinatra/sinatra.git
452
500
  cd sinatra
453
501
  cd path/to/your_project
454
502
  ln -s ../sinatra/
@@ -462,7 +510,7 @@ screencasts about Git, which you can find here: http://www.gitcasts.com/
462
510
 
463
511
  at the top of your sinatra_app.rb file:
464
512
 
465
- $:.unshift File.dirname(__FILE__) + '/sinatra/lib'
513
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/sinatra/lib'
466
514
  require 'sinatra'
467
515
 
468
516
  get '/about' do
@@ -472,9 +520,8 @@ at the top of your sinatra_app.rb file:
472
520
  === Contributing a Patch
473
521
 
474
522
  There are several ways to do this. Probably the easiest (and preferred) way is
475
- to fork Sinatra on GitHub (http://github.com/bmizerany/sinatra), push your
476
- changes to your Sinatra repo, and then send Blake Mizerany (bmizerany on
477
- GitHub) a pull request.
523
+ to fork Sinatra on GitHub (http://github.com/sinatra/sinatra), push your
524
+ changes to your Sinatra repo and file a ticket in lighthouse (sinatra.lighthouseapp.com) where we can discuss it.
478
525
 
479
526
  You can also create a patch file and attach it to a feature request or bug fix
480
527
  on the issue tracker (see below) or send it to the mailing list (see Community
data/Rakefile CHANGED
@@ -57,7 +57,12 @@ file package('.gem') => %w[dist/ sinatra.gemspec] + spec.files do |f|
57
57
  end
58
58
 
59
59
  file package('.tar.gz') => %w[dist/] + spec.files do |f|
60
- sh "git archive --format=tar HEAD | gzip > #{f.name}"
60
+ sh <<-SH
61
+ git archive \
62
+ --prefix=sinatra-#{source_version}/ \
63
+ --format=tar \
64
+ HEAD | gzip > #{f.name}
65
+ SH
61
66
  end
62
67
 
63
68
  # Rubyforge Release / Publish Tasks ==================================
@@ -67,6 +72,7 @@ task 'publish:doc' => 'doc/api/index.html' do
67
72
  sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/sinatra/'
68
73
  end
69
74
 
75
+ desc 'Publish gem and tarball to rubyforge'
70
76
  task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t|
71
77
  sh <<-end
72
78
  rubyforge add_release sinatra sinatra #{spec.version} #{package('.gem')} &&
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  context "Simple Events" do
4
-
5
4
  def simple_request_hash(method, path)
6
5
  Rack::Request.new({
7
6
  'REQUEST_METHOD' => method.to_s.upcase,
@@ -14,16 +13,16 @@ context "Simple Events" do
14
13
 
15
14
  def invoke_simple(path, request_path, &b)
16
15
  params = nil
17
- mock_app {
18
- get path do
19
- params = self.params
20
- b.call if b
21
- end
22
- }
16
+ get path do
17
+ params = self.params
18
+ b.call if b
19
+ end
23
20
  get_it request_path
24
21
  MockResult.new(b, params)
25
22
  end
26
23
 
24
+ setup { Sinatra.application = nil }
25
+
27
26
  specify "return last value" do
28
27
  block = Proc.new { 'Simple' }
29
28
  result = invoke_simple('/', '/', &block)
@@ -38,6 +37,7 @@ context "Simple Events" do
38
37
  result.params.should.equal "foo" => 'a', "bar" => 'b'
39
38
 
40
39
  # unscapes
40
+ Sinatra.application = nil
41
41
  result = invoke_simple('/:foo/:bar', '/a/blake%20mizerany')
42
42
  result.should.not.be.nil
43
43
  result.params.should.equal "foo" => 'a', "bar" => 'blake mizerany'
@@ -48,14 +48,17 @@ context "Simple Events" do
48
48
  result.should.not.be.nil
49
49
  result.params.should.equal "foo" => 'a', "bar" => 'b'
50
50
 
51
+ Sinatra.application = nil
51
52
  result = invoke_simple('/?:foo?/?:bar?', '/a/')
52
53
  result.should.not.be.nil
53
54
  result.params.should.equal "foo" => 'a', "bar" => nil
54
55
 
56
+ Sinatra.application = nil
55
57
  result = invoke_simple('/?:foo?/?:bar?', '/a')
56
58
  result.should.not.be.nil
57
59
  result.params.should.equal "foo" => 'a', "bar" => nil
58
60
 
61
+ Sinatra.application = nil
59
62
  result = invoke_simple('/:foo?/?:bar?', '/')
60
63
  result.should.not.be.nil
61
64
  result.params.should.equal "foo" => nil, "bar" => nil