jellyfish 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@
2
2
  require 'jellyfish/test'
3
3
 
4
4
  describe 'Sinatra mapped_error_test.rb' do
5
- behaves_like :jellyfish
5
+ paste :jellyfish
6
6
 
7
7
  exp = Class.new(RuntimeError)
8
8
 
9
- should 'invoke handlers registered with handle when raised' do
9
+ would 'invoke handlers registered with handle when raised' do
10
10
  app = Class.new{
11
11
  include Jellyfish
12
12
  handle(exp){ 'Foo!' }
@@ -20,7 +20,7 @@ describe 'Sinatra mapped_error_test.rb' do
20
20
  body .should.eq ['Foo!']
21
21
  end
22
22
 
23
- should 'pass the exception object to the error handler' do
23
+ would 'pass the exception object to the error handler' do
24
24
  app = Class.new{
25
25
  include Jellyfish
26
26
  handle(exp){ |e| e.should.kind_of?(exp) }
@@ -29,7 +29,7 @@ describe 'Sinatra mapped_error_test.rb' do
29
29
  get('/', app)
30
30
  end
31
31
 
32
- should 'use the StandardError handler if no matching handler found' do
32
+ would 'use the StandardError handler if no matching handler found' do
33
33
  app = Class.new{
34
34
  include Jellyfish
35
35
  handle(StandardError){ 'StandardError!' }
@@ -41,7 +41,7 @@ describe 'Sinatra mapped_error_test.rb' do
41
41
  body .should.eq ['StandardError!']
42
42
  end
43
43
 
44
- should 'favour subclass handler over superclass handler if available' do
44
+ would 'favour subclass handler over superclass handler if available' do
45
45
  app = Class.new{
46
46
  include Jellyfish
47
47
  handle(StandardError){ 'StandardError!' }
@@ -58,7 +58,7 @@ describe 'Sinatra mapped_error_test.rb' do
58
58
  handlers[exp].should.eq handlers[RuntimeError]
59
59
  end
60
60
 
61
- should 'pass the exception to the handler' do
61
+ would 'pass the exception to the handler' do
62
62
  app = Class.new{
63
63
  include Jellyfish
64
64
  handle(exp){ |e|
@@ -72,7 +72,7 @@ describe 'Sinatra mapped_error_test.rb' do
72
72
  body.should.eq ['looks good']
73
73
  end
74
74
 
75
- should 'raise errors from the app when handle_exceptions is false' do
75
+ would 'raise errors from the app when handle_exceptions is false' do
76
76
  app = Class.new{
77
77
  include Jellyfish
78
78
  handle_exceptions false
@@ -82,7 +82,7 @@ describe 'Sinatra mapped_error_test.rb' do
82
82
  lambda{ get('/', app) }.should.raise(exp)
83
83
  end
84
84
 
85
- should 'call error handlers even when handle_exceptions is false' do
85
+ would 'call error handlers even when handle_exceptions is false' do
86
86
  app = Class.new{
87
87
  include Jellyfish
88
88
  handle_exceptions false
@@ -94,7 +94,7 @@ describe 'Sinatra mapped_error_test.rb' do
94
94
  body.should.eq ["she's there."]
95
95
  end
96
96
 
97
- should 'catch Jellyfish::NotFound' do
97
+ would 'catch Jellyfish::NotFound' do
98
98
  app = Class.new{
99
99
  include Jellyfish
100
100
  get('/'){ not_found }
@@ -104,7 +104,7 @@ describe 'Sinatra mapped_error_test.rb' do
104
104
  status.should.eq 404
105
105
  end
106
106
 
107
- should 'handle subclasses of Jellyfish::NotFound' do
107
+ would 'handle subclasses of Jellyfish::NotFound' do
108
108
  e = Class.new(Jellyfish::NotFound)
109
109
  app = Class.new{
110
110
  include Jellyfish
@@ -115,7 +115,7 @@ describe 'Sinatra mapped_error_test.rb' do
115
115
  status.should.eq 404
116
116
  end
117
117
 
118
- should 'no longer cascade with Jellyfish::NotFound' do
118
+ would 'no longer cascade with Jellyfish::NotFound' do
119
119
  app = Class.new{
120
120
  include Jellyfish
121
121
  get('/'){ not_found }
@@ -128,7 +128,7 @@ describe 'Sinatra mapped_error_test.rb' do
128
128
  status.should.eq 404
129
129
  end
130
130
 
131
- should 'cascade with Jellyfish::Cascade' do
131
+ would 'cascade with Jellyfish::Cascade' do
132
132
  app = Class.new{
133
133
  include Jellyfish
134
134
  get('/'){ cascade }
@@ -142,7 +142,7 @@ describe 'Sinatra mapped_error_test.rb' do
142
142
  body .should.eq ['reach']
143
143
  end
144
144
 
145
- should 'inherit error mappings from base class' do
145
+ would 'inherit error mappings from base class' do
146
146
  sup = Class.new{
147
147
  include Jellyfish
148
148
  handle(exp){ 'sup' }
@@ -155,7 +155,7 @@ describe 'Sinatra mapped_error_test.rb' do
155
155
  body.should.eq ['sup']
156
156
  end
157
157
 
158
- should 'override error mappings in base class' do
158
+ would 'override error mappings in base class' do
159
159
  sup = Class.new{
160
160
  include Jellyfish
161
161
  handle(exp){ 'sup' }
@@ -165,7 +165,6 @@ describe 'Sinatra mapped_error_test.rb' do
165
165
  get('/'){ raise exp }
166
166
  }.new
167
167
 
168
-
169
168
  _, _, body = get('/', app)
170
169
  body.should.eq ['sub']
171
170
  end
@@ -3,7 +3,7 @@ require 'jellyfish/test'
3
3
 
4
4
  # stolen from sinatra
5
5
  describe 'Sinatra filter_test.rb' do
6
- behaves_like :jellyfish
6
+ paste :jellyfish
7
7
 
8
8
  def new_app base=Object, &block
9
9
  Class.new(base){
@@ -13,7 +13,7 @@ describe 'Sinatra filter_test.rb' do
13
13
  }.new
14
14
  end
15
15
 
16
- should 'executes filters in the order defined' do
16
+ would 'executes filters in the order defined' do
17
17
  count = 0
18
18
  app = new_app{
19
19
  get { count.should.eq 0; count = 1 }
@@ -27,7 +27,7 @@ describe 'Sinatra filter_test.rb' do
27
27
  body .should.eq ['Hello World']
28
28
  end
29
29
 
30
- should 'modify env' do
30
+ would 'modify env' do
31
31
  app = new_app{
32
32
  get{ env['BOO'] = 'MOO' }
33
33
  get('/foo'){ env['BOO'] }
@@ -38,7 +38,7 @@ describe 'Sinatra filter_test.rb' do
38
38
  body .should.eq ['MOO']
39
39
  end
40
40
 
41
- should 'modify instance variables available to routes' do
41
+ would 'modify instance variables available to routes' do
42
42
  app = new_app{
43
43
  get{ @foo = 'bar' }
44
44
  get('/foo') { @foo }
@@ -49,7 +49,7 @@ describe 'Sinatra filter_test.rb' do
49
49
  body .should.eq ['bar']
50
50
  end
51
51
 
52
- should 'allows redirects' do
52
+ would 'allows redirects' do
53
53
  app = new_app{
54
54
  get{ found '/bar' }
55
55
  get('/foo') do
@@ -64,7 +64,7 @@ describe 'Sinatra filter_test.rb' do
64
64
  body.join .should =~ %r{<h1>Jellyfish found: /bar</h1>}
65
65
  end
66
66
 
67
- should 'not modify the response with its return value' do
67
+ would 'not modify the response with its return value' do
68
68
  app = new_app{
69
69
  get{ 'Hello World!' }
70
70
  get '/foo' do
@@ -78,7 +78,7 @@ describe 'Sinatra filter_test.rb' do
78
78
  body .should.eq ['cool']
79
79
  end
80
80
 
81
- should 'modify the response with halt' do
81
+ would 'modify the response with halt' do
82
82
  app = new_app{
83
83
  get('/foo'){ halt [302, {}, ['Hi']] }
84
84
  get('/foo'){ 'should not happen' }
@@ -90,7 +90,7 @@ describe 'Sinatra filter_test.rb' do
90
90
  get('/bar', app).should.eq [402, {}, ['Ho']]
91
91
  end
92
92
 
93
- should 'give you access to params' do
93
+ would 'give you access to params' do
94
94
  app = new_app{
95
95
  get{ @foo = Rack::Request.new(env).params['foo'] }
96
96
  get('/foo'){ @foo.reverse }
@@ -101,7 +101,7 @@ describe 'Sinatra filter_test.rb' do
101
101
  body .should.eq ['looc']
102
102
  end
103
103
 
104
- should 'run filters defined in superclasses' do
104
+ would 'run filters defined in superclasses' do
105
105
  sup = new_app{ get{ @foo = 'hello from superclass' } }.class
106
106
  app = new_app(sup){ get('/foo'){ @foo } }
107
107
 
@@ -112,7 +112,7 @@ describe 'Sinatra filter_test.rb' do
112
112
  app.class.routes['get'].size.should.eq 2
113
113
  end
114
114
 
115
- should 'take an optional route pattern' do
115
+ would 'take an optional route pattern' do
116
116
  ran_filter = false
117
117
  app = new_app{
118
118
  get(%r{^/b}){ ran_filter = true }
@@ -125,7 +125,7 @@ describe 'Sinatra filter_test.rb' do
125
125
  ran_filter.should.eq true
126
126
  end
127
127
 
128
- should 'generate block arguments from route pattern' do
128
+ would 'generate block arguments from route pattern' do
129
129
  subpath = nil
130
130
  app = new_app{
131
131
  get(%r{^/foo/(\w+)}){ |m| subpath = m[1] }
@@ -134,7 +134,7 @@ describe 'Sinatra filter_test.rb' do
134
134
  subpath.should.eq 'bar'
135
135
  end
136
136
 
137
- should 'execute before and after filters in correct order' do
137
+ would 'execute before and after filters in correct order' do
138
138
  invoked = 0
139
139
  app = new_app{
140
140
  get { invoked = 2 }
@@ -148,7 +148,7 @@ describe 'Sinatra filter_test.rb' do
148
148
  invoked.should.eq 8
149
149
  end
150
150
 
151
- should 'execute filters in the order defined' do
151
+ would 'execute filters in the order defined' do
152
152
  count = 0
153
153
  app = new_app{
154
154
  get('/'){ body 'Hello World' }
@@ -168,7 +168,7 @@ describe 'Sinatra filter_test.rb' do
168
168
  body .should.eq ['Hello World']
169
169
  end
170
170
 
171
- should 'allow redirects' do
171
+ would 'allow redirects' do
172
172
  app = new_app{
173
173
  get('/foo'){ 'ORLY' }
174
174
  get { found '/bar' }
@@ -180,7 +180,7 @@ describe 'Sinatra filter_test.rb' do
180
180
  body.join .should =~ %r{<h1>Jellyfish found: /bar</h1>}
181
181
  end
182
182
 
183
- should 'not modify the response with its return value' do
183
+ would 'not modify the response with its return value' do
184
184
  app = new_app{
185
185
  get('/foo'){ body 'cool' }
186
186
  get { 'Hello World!' }
@@ -191,7 +191,7 @@ describe 'Sinatra filter_test.rb' do
191
191
  body .should.eq ['cool']
192
192
  end
193
193
 
194
- should 'modify the response with halt' do
194
+ would 'modify the response with halt' do
195
195
  app = new_app{
196
196
  get('/foo'){ 'should not be returned' }
197
197
  get{ halt [302, {}, ['Hi']] }
@@ -202,7 +202,7 @@ describe 'Sinatra filter_test.rb' do
202
202
  body .should.eq ['Hi']
203
203
  end
204
204
 
205
- should 'take an optional route pattern' do
205
+ would 'take an optional route pattern' do
206
206
  ran_filter = false
207
207
  app = new_app{
208
208
  get('/foo') {}
@@ -19,10 +19,10 @@ end
19
19
 
20
20
  # stolen from sinatra
21
21
  describe 'Sinatra routing_test.rb' do
22
- behaves_like :jellyfish
22
+ paste :jellyfish
23
23
 
24
24
  %w[get put post delete options patch head].each do |verb|
25
- should "define #{verb.upcase} request handlers with #{verb}" do
25
+ would "define #{verb.upcase} request handlers with #{verb}" do
26
26
  app = Class.new{
27
27
  include Jellyfish
28
28
  send verb, '/hello' do
@@ -36,7 +36,7 @@ describe 'Sinatra routing_test.rb' do
36
36
  end
37
37
  end
38
38
 
39
- should '404s when no route satisfies the request' do
39
+ would '404s when no route satisfies the request' do
40
40
  app = Class.new{
41
41
  include Jellyfish
42
42
  get('/foo'){}
@@ -45,7 +45,7 @@ describe 'Sinatra routing_test.rb' do
45
45
  status.should.eq 404
46
46
  end
47
47
 
48
- should 'allows using unicode' do
48
+ would 'allows using unicode' do
49
49
  app = Class.new{
50
50
  include Jellyfish
51
51
  controller_include Jellyfish::NormalizedPath
@@ -55,7 +55,7 @@ describe 'Sinatra routing_test.rb' do
55
55
  status.should.eq 200
56
56
  end
57
57
 
58
- should 'handle encoded slashes correctly' do
58
+ would 'handle encoded slashes correctly' do
59
59
  app = Class.new{
60
60
  include Jellyfish
61
61
  controller_include Jellyfish::NormalizedPath
@@ -66,7 +66,7 @@ describe 'Sinatra routing_test.rb' do
66
66
  body .should.eq ['foo/bar']
67
67
  end
68
68
 
69
- should 'override the content-type in error handlers' do
69
+ would 'override the content-type in error handlers' do
70
70
  app = Class.new{
71
71
  include Jellyfish
72
72
  get{
@@ -91,7 +91,7 @@ describe 'Sinatra routing_test.rb' do
91
91
  body .should.eq ['<h1>Not Found</h1>']
92
92
  end
93
93
 
94
- should 'match empty PATH_INFO to "/" if no route is defined for ""' do
94
+ would 'match empty PATH_INFO to "/" if no route is defined for ""' do
95
95
  app = Class.new{
96
96
  include Jellyfish
97
97
  controller_include Jellyfish::NormalizedPath
@@ -103,7 +103,7 @@ describe 'Sinatra routing_test.rb' do
103
103
  body .should.eq ['worked']
104
104
  end
105
105
 
106
- should 'exposes params with indifferent hash' do
106
+ would 'exposes params with indifferent hash' do
107
107
  app = Class.new{
108
108
  include Jellyfish
109
109
  controller_include Jellyfish::NormalizedParams
@@ -119,7 +119,7 @@ describe 'Sinatra routing_test.rb' do
119
119
  body.should.eq ['well, alright']
120
120
  end
121
121
 
122
- should 'merges named params and query string params in params' do
122
+ would 'merges named params and query string params in params' do
123
123
  app = Class.new{
124
124
  include Jellyfish
125
125
  controller_include Jellyfish::NormalizedParams
@@ -134,7 +134,7 @@ describe 'Sinatra routing_test.rb' do
134
134
  status.should.eq 200
135
135
  end
136
136
 
137
- should 'support named captures like %r{/hello/(?<person>[^/?#]+)}' do
137
+ would 'support named captures like %r{/hello/(?<person>[^/?#]+)}' do
138
138
  app = Class.new{
139
139
  include Jellyfish
140
140
  get Regexp.new('/hello/(?<person>[^/?#]+)') do |m|
@@ -146,7 +146,7 @@ describe 'Sinatra routing_test.rb' do
146
146
  body.should.eq ['Hello Frank']
147
147
  end
148
148
 
149
- should 'support optional named captures' do
149
+ would 'support optional named captures' do
150
150
  app = Class.new{
151
151
  include Jellyfish
152
152
  get Regexp.new('/page(?<format>.[^/?#]+)?') do |m|
@@ -167,7 +167,7 @@ describe 'Sinatra routing_test.rb' do
167
167
  body .should.eq ['format=']
168
168
  end
169
169
 
170
- should 'not concatinate params with the same name' do
170
+ would 'not concatinate params with the same name' do
171
171
  app = Class.new{
172
172
  include Jellyfish
173
173
  controller_include Jellyfish::NormalizedParams
@@ -179,7 +179,7 @@ describe 'Sinatra routing_test.rb' do
179
179
  body.should.eq ['a']
180
180
  end
181
181
 
182
- should 'support basic nested params' do
182
+ would 'support basic nested params' do
183
183
  app = Class.new{
184
184
  include Jellyfish
185
185
  get('/hi'){ request.params['person']['name'] }
@@ -191,7 +191,7 @@ describe 'Sinatra routing_test.rb' do
191
191
  body.should.eq ['John Doe']
192
192
  end
193
193
 
194
- should "expose nested params with indifferent hash" do
194
+ would "expose nested params with indifferent hash" do
195
195
  app = Class.new{
196
196
  include Jellyfish
197
197
  controller_include Jellyfish::NormalizedParams
@@ -207,7 +207,7 @@ describe 'Sinatra routing_test.rb' do
207
207
  body.should.eq ['well, alright']
208
208
  end
209
209
 
210
- should 'preserve non-nested params' do
210
+ would 'preserve non-nested params' do
211
211
  app = Class.new{
212
212
  include Jellyfish
213
213
  get '/foo' do
@@ -224,7 +224,7 @@ describe 'Sinatra routing_test.rb' do
224
224
  body .should.eq ['looks good']
225
225
  end
226
226
 
227
- should 'match paths that include spaces encoded with %20' do
227
+ would 'match paths that include spaces encoded with %20' do
228
228
  app = Class.new{
229
229
  include Jellyfish
230
230
  controller_include Jellyfish::NormalizedPath
@@ -236,7 +236,7 @@ describe 'Sinatra routing_test.rb' do
236
236
  body .should.eq ['looks good']
237
237
  end
238
238
 
239
- should 'match paths that include spaces encoded with +' do
239
+ would 'match paths that include spaces encoded with +' do
240
240
  app = Class.new{
241
241
  include Jellyfish
242
242
  controller_include Jellyfish::NormalizedPath
@@ -248,7 +248,7 @@ describe 'Sinatra routing_test.rb' do
248
248
  body .should.eq ['looks good']
249
249
  end
250
250
 
251
- should 'make regular expression captures available' do
251
+ would 'make regular expression captures available' do
252
252
  app = Class.new{
253
253
  include Jellyfish
254
254
  get(/^\/fo(.*)\/ba(.*)/) do |m|
@@ -262,7 +262,7 @@ describe 'Sinatra routing_test.rb' do
262
262
  body .should.eq ['right on']
263
263
  end
264
264
 
265
- it 'supports regular expression look-alike routes' do
265
+ would 'support regular expression look-alike routes' do
266
266
  app = Class.new{
267
267
  include Jellyfish
268
268
  controller_include Jellyfish::NormalizedParams
@@ -287,12 +287,12 @@ describe 'Sinatra routing_test.rb' do
287
287
  body .should.eq ['right on']
288
288
  end
289
289
 
290
- should 'raise a TypeError when pattern is not a String or Regexp' do
290
+ would 'raise a TypeError when pattern is not a String or Regexp' do
291
291
  lambda{ Class.new{ include Jellyfish; get(42){} } }.
292
292
  should.raise(TypeError)
293
293
  end
294
294
 
295
- should 'return response immediately on next or halt' do
295
+ would 'return response immediately on next or halt' do
296
296
  app = Class.new{
297
297
  include Jellyfish
298
298
  controller_include Jellyfish::MultiActions
@@ -316,7 +316,7 @@ describe 'Sinatra routing_test.rb' do
316
316
  end
317
317
  end
318
318
 
319
- should 'halt with a response tuple' do
319
+ would 'halt with a response tuple' do
320
320
  app = Class.new{
321
321
  include Jellyfish
322
322
  controller_include Jellyfish::MultiActions
@@ -332,7 +332,7 @@ describe 'Sinatra routing_test.rb' do
332
332
  body .should.eq ['Hello World']
333
333
  end
334
334
 
335
- should 'transition to the next matching route on next' do
335
+ would 'transition to the next matching route on next' do
336
336
  app = Class.new{
337
337
  include Jellyfish
338
338
  controller_include Jellyfish::MultiActions, Jellyfish::NormalizedParams
@@ -352,7 +352,7 @@ describe 'Sinatra routing_test.rb' do
352
352
  body .should.eq ['Hello World']
353
353
  end
354
354
 
355
- should 'match routes defined in superclasses' do
355
+ would 'match routes defined in superclasses' do
356
356
  sup = Class.new{
357
357
  include Jellyfish
358
358
  get('/foo'){ 'foo' }
@@ -368,7 +368,7 @@ describe 'Sinatra routing_test.rb' do
368
368
  end
369
369
  end
370
370
 
371
- should 'match routes itself first then downward app' do
371
+ would 'match routes itself first then downward app' do
372
372
  sup = Class.new{
373
373
  include Jellyfish
374
374
  get('/foo'){ 'foo sup' }
@@ -388,7 +388,7 @@ describe 'Sinatra routing_test.rb' do
388
388
  body .should.eq ['bar sup']
389
389
  end
390
390
 
391
- should 'allow using call to fire another request internally' do
391
+ would 'allow using call to fire another request internally' do
392
392
  app = Class.new{
393
393
  include Jellyfish
394
394
  get '/foo' do
@@ -408,7 +408,7 @@ describe 'Sinatra routing_test.rb' do
408
408
  body .should.eq ['BAR']
409
409
  end
410
410
 
411
- should 'play well with other routing middleware' do
411
+ would 'play well with other routing middleware' do
412
412
  middleware = Class.new{include Jellyfish}
413
413
  inner_app = Class.new{include Jellyfish; get('/foo'){ 'hello' } }
414
414
  app = Rack::Builder.app do