rtomayko-sinatra 0.8.10 → 0.9.0

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.
@@ -1,6 +1,10 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  describe "Middleware" do
6
+ include Sinatra::Test
7
+
4
8
  before do
5
9
  @app = mock_app(Sinatra::Default) {
6
10
  get '/*' do
@@ -27,8 +31,8 @@ describe "Middleware" do
27
31
  it "is added with Sinatra::Application.use" do
28
32
  @app.use UpcaseMiddleware
29
33
  get '/hello-world'
30
- assert ok?
31
- assert_equal '/HELLO-WORLD', body
34
+ response.should.be.ok
35
+ body.should.equal '/HELLO-WORLD'
32
36
  end
33
37
 
34
38
  class DowncaseMiddleware < MockMiddleware
@@ -42,17 +46,18 @@ describe "Middleware" do
42
46
  @app.use UpcaseMiddleware
43
47
  @app.use DowncaseMiddleware
44
48
  get '/Foo'
45
- assert_equal "/foo", body
46
- assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
49
+ body.should.equal "/foo"
50
+ response['X-Tests'].should.equal "UpcaseMiddleware, DowncaseMiddleware"
47
51
  end
48
52
 
49
53
  specify "resets the prebuilt pipeline when new middleware is added" do
50
54
  @app.use UpcaseMiddleware
51
55
  get '/Foo'
52
- assert_equal "/FOO", body
56
+ body.should.equal "/FOO"
53
57
  @app.use DowncaseMiddleware
54
58
  get '/Foo'
55
- assert_equal '/foo', body
56
- assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
59
+ body.should.equal '/foo'
60
+ response['X-Tests'].should.equal "UpcaseMiddleware, DowncaseMiddleware"
57
61
  end
62
+
58
63
  end
data/test/options_test.rb CHANGED
@@ -1,27 +1,33 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  describe 'Options' do
4
- before { @app = Class.new(Sinatra::Base) }
6
+ include Sinatra::Test
7
+
8
+ before do
9
+ @app = Class.new(Sinatra::Base)
10
+ end
5
11
 
6
12
  it 'sets options to literal values' do
7
13
  @app.set(:foo, 'bar')
8
- assert @app.respond_to?(:foo)
9
- assert_equal 'bar', @app.foo
14
+ @app.should.respond_to? :foo
15
+ @app.foo.should.equal 'bar'
10
16
  end
11
17
 
12
18
  it 'sets options to Procs' do
13
19
  @app.set(:foo, Proc.new { 'baz' })
14
- assert @app.respond_to?(:foo)
15
- assert_equal 'baz', @app.foo
20
+ @app.should.respond_to? :foo
21
+ @app.foo.should.equal 'baz'
16
22
  end
17
23
 
18
24
  it "sets multiple options with a Hash" do
19
25
  @app.set :foo => 1234,
20
26
  :bar => 'Hello World',
21
27
  :baz => Proc.new { 'bizzle' }
22
- assert_equal 1234, @app.foo
23
- assert_equal 'Hello World', @app.bar
24
- assert_equal 'bizzle', @app.baz
28
+ @app.foo.should.equal 1234
29
+ @app.bar.should.equal 'Hello World'
30
+ @app.baz.should.equal 'bizzle'
25
31
  end
26
32
 
27
33
  it 'inherits option methods when subclassed' do
@@ -29,10 +35,10 @@ describe 'Options' do
29
35
  @app.set :biz, Proc.new { 'baz' }
30
36
 
31
37
  sub = Class.new(@app)
32
- assert sub.respond_to?(:foo)
33
- assert_equal 'bar', sub.foo
34
- assert sub.respond_to?(:biz)
35
- assert_equal 'baz', sub.biz
38
+ sub.should.respond_to :foo
39
+ sub.foo.should.equal 'bar'
40
+ sub.should.respond_to :biz
41
+ sub.biz.should.equal 'baz'
36
42
  end
37
43
 
38
44
  it 'overrides options in subclass' do
@@ -40,23 +46,23 @@ describe 'Options' do
40
46
  @app.set :biz, Proc.new { 'baz' }
41
47
  sub = Class.new(@app)
42
48
  sub.set :foo, 'bling'
43
- assert_equal 'bling', sub.foo
44
- assert_equal 'bar', @app.foo
49
+ sub.foo.should.equal 'bling'
50
+ @app.foo.should.equal 'bar'
45
51
  end
46
52
 
47
53
  it 'creates setter methods when first defined' do
48
54
  @app.set :foo, 'bar'
49
- assert @app.respond_to?('foo=')
55
+ @app.should.respond_to 'foo='
50
56
  @app.foo = 'biz'
51
- assert_equal 'biz', @app.foo
57
+ @app.foo.should.equal 'biz'
52
58
  end
53
59
 
54
60
  it 'creates predicate methods when first defined' do
55
61
  @app.set :foo, 'hello world'
56
- assert @app.respond_to?(:foo?)
57
- assert @app.foo?
62
+ @app.should.respond_to :foo?
63
+ @app.foo?.should.be true
58
64
  @app.set :foo, nil
59
- assert !@app.foo?
65
+ @app.foo?.should.be false
60
66
  end
61
67
 
62
68
  it 'uses existing setter methods if detected' do
@@ -70,28 +76,28 @@ describe 'Options' do
70
76
  end
71
77
 
72
78
  @app.set :foo, 'bam'
73
- assert_equal 'oops', @app.foo
79
+ @app.foo.should.equal 'oops'
74
80
  end
75
81
 
76
82
  it "sets multiple options to true with #enable" do
77
83
  @app.enable :sessions, :foo, :bar
78
- assert @app.sessions
79
- assert @app.foo
80
- assert @app.bar
84
+ @app.sessions.should.be true
85
+ @app.foo.should.be true
86
+ @app.bar.should.be true
81
87
  end
82
88
 
83
89
  it "sets multiple options to false with #disable" do
84
90
  @app.disable :sessions, :foo, :bar
85
- assert !@app.sessions
86
- assert !@app.foo
87
- assert !@app.bar
91
+ @app.sessions.should.be false
92
+ @app.foo.should.be false
93
+ @app.bar.should.be false
88
94
  end
89
95
 
90
96
  it 'enables MethodOverride middleware when :methodoverride is enabled' do
91
97
  @app.set :methodoverride, true
92
98
  @app.put('/') { 'okay' }
93
99
  post '/', {'_method'=>'PUT'}, {}
94
- assert_equal 200, status
95
- assert_equal 'okay', body
100
+ status.should.equal 200
101
+ body.should.equal 'okay'
96
102
  end
97
103
  end
data/test/reload_test.rb CHANGED
@@ -1,9 +1,13 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  $reload_count = 0
4
6
  $reload_app = nil
5
7
 
6
8
  describe "Reloading" do
9
+ include Sinatra::Test
10
+
7
11
  before {
8
12
  @app = mock_app(Sinatra::Default)
9
13
  $reload_app = @app
@@ -16,31 +20,31 @@ describe "Reloading" do
16
20
  it 'is enabled by default when in development and the app_file is set' do
17
21
  @app.set :app_file, __FILE__
18
22
  @app.set :environment, :development
19
- assert_same true, @app.reload
20
- assert_same true, @app.reload?
23
+ @app.reload.should.be true
24
+ @app.reload?.should.be true
21
25
  end
22
26
 
23
27
  it 'is disabled by default when running in non-development environment' do
24
28
  @app.set :app_file, __FILE__
25
29
  @app.set :environment, :test
26
- assert !@app.reload
27
- assert_same false, @app.reload?
30
+ @app.reload.should.not.be true
31
+ @app.reload?.should.be false
28
32
  end
29
33
 
30
34
  it 'is disabled by default when no app_file is available' do
31
35
  @app.set :app_file, nil
32
36
  @app.set :environment, :development
33
- assert !@app.reload
34
- assert_same false, @app.reload?
37
+ @app.reload.should.not.be true
38
+ @app.reload?.should.be false
35
39
  end
36
40
 
37
41
  it 'can be turned off explicitly' do
38
42
  @app.set :app_file, __FILE__
39
43
  @app.set :environment, :development
40
- assert_same true, @app.reload
44
+ @app.reload.should.be true
41
45
  @app.set :reload, false
42
- assert_same false, @app.reload
43
- assert_same false, @app.reload?
46
+ @app.reload.should.be false
47
+ @app.reload?.should.be false
44
48
  end
45
49
 
46
50
  it 'reloads the app_file each time a request is made' do
@@ -49,13 +53,13 @@ describe "Reloading" do
49
53
  @app.get('/') { 'Hello World' }
50
54
 
51
55
  get '/'
52
- assert_equal 200, status
53
- assert_equal 'Hello from reload file', body
54
- assert_equal 1, $reload_count
56
+ status.should.equal 200
57
+ body.should.equal 'Hello from reload file'
58
+ $reload_count.should.equal 1
55
59
 
56
60
  get '/'
57
- assert_equal 200, status
58
- assert_equal 'Hello from reload file', body
59
- assert_equal 2, $reload_count
61
+ status.should.equal 200
62
+ body.should.equal 'Hello from reload file'
63
+ $reload_count.should.equal 2
60
64
  end
61
65
  end
data/test/request_test.rb CHANGED
@@ -1,18 +1,11 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  describe 'Sinatra::Request' do
4
6
  it 'responds to #user_agent' do
5
7
  request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
6
- assert request.respond_to?(:user_agent)
7
- assert_equal 'Test', request.user_agent
8
- end
9
-
10
- it 'parses POST params when Content-Type is form-dataish' do
11
- request = Sinatra::Request.new(
12
- 'REQUEST_METHOD' => 'PUT',
13
- 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
14
- 'rack.input' => StringIO.new('foo=bar')
15
- )
16
- assert_equal 'bar', request.params['foo']
8
+ request.should.respond_to :user_agent
9
+ request.user_agent.should.equal 'Test'
17
10
  end
18
11
  end
data/test/result_test.rb CHANGED
@@ -1,6 +1,10 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  describe 'Result Handling' do
6
+ include Sinatra::Test
7
+
4
8
  it "sets response.body when result is a String" do
5
9
  mock_app {
6
10
  get '/' do
@@ -9,8 +13,8 @@ describe 'Result Handling' do
9
13
  }
10
14
 
11
15
  get '/'
12
- assert ok?
13
- assert_equal 'Hello World', body
16
+ should.be.ok
17
+ body.should.equal 'Hello World'
14
18
  end
15
19
 
16
20
  it "sets response.body when result is an Array of Strings" do
@@ -21,8 +25,8 @@ describe 'Result Handling' do
21
25
  }
22
26
 
23
27
  get '/'
24
- assert ok?
25
- assert_equal 'HelloWorld', body
28
+ should.be.ok
29
+ body.should.equal 'HelloWorld'
26
30
  end
27
31
 
28
32
  it "sets response.body when result responds to #each" do
@@ -35,8 +39,8 @@ describe 'Result Handling' do
35
39
  }
36
40
 
37
41
  get '/'
38
- assert ok?
39
- assert_equal 'Hello World', body
42
+ should.be.ok
43
+ body.should.equal 'Hello World'
40
44
  end
41
45
 
42
46
  it "sets response.body to [] when result is nil" do
@@ -47,8 +51,8 @@ describe 'Result Handling' do
47
51
  }
48
52
 
49
53
  get '/'
50
- assert ok?
51
- assert_equal '', body
54
+ should.be.ok
55
+ body.should.equal ''
52
56
  end
53
57
 
54
58
  it "sets status, headers, and body when result is a Rack response tuple" do
@@ -59,9 +63,9 @@ describe 'Result Handling' do
59
63
  }
60
64
 
61
65
  get '/'
62
- assert_equal 205, status
63
- assert_equal 'foo/bar', response['Content-Type']
64
- assert_equal 'Hello World', body
66
+ status.should.equal 205
67
+ response['Content-Type'].should.equal 'foo/bar'
68
+ body.should.equal 'Hello World'
65
69
  end
66
70
 
67
71
  it "sets status and body when result is a two-tuple" do
@@ -72,8 +76,8 @@ describe 'Result Handling' do
72
76
  }
73
77
 
74
78
  get '/'
75
- assert_equal 409, status
76
- assert_equal 'formula of', body
79
+ status.should.equal 409
80
+ body.should.equal 'formula of'
77
81
  end
78
82
 
79
83
  it "sets status when result is a Fixnum status code" do
@@ -82,7 +86,7 @@ describe 'Result Handling' do
82
86
  }
83
87
 
84
88
  get '/'
85
- assert_equal 205, status
86
- assert_equal '', body
89
+ status.should.equal 205
90
+ body.should.be.empty
87
91
  end
88
92
  end
data/test/routing_test.rb CHANGED
@@ -1,6 +1,10 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require 'test/spec'
2
+ require 'sinatra/base'
3
+ require 'sinatra/test'
2
4
 
3
5
  describe "Routing" do
6
+ include Sinatra::Test
7
+
4
8
  %w[get put post delete head].each do |verb|
5
9
  it "defines #{verb.upcase} request handlers with #{verb}" do
6
10
  mock_app {
@@ -11,8 +15,8 @@ describe "Routing" do
11
15
 
12
16
  request = Rack::MockRequest.new(@app)
13
17
  response = request.request(verb.upcase, '/hello', {})
14
- assert response.ok?
15
- assert_equal 'Hello World', response.body
18
+ response.should.be.ok
19
+ response.body.should.equal 'Hello World'
16
20
  end
17
21
  end
18
22
 
@@ -21,30 +25,30 @@ describe "Routing" do
21
25
  get('/foo') { }
22
26
  }
23
27
  get '/bar'
24
- assert_equal 404, status
28
+ status.should.equal 404
25
29
  end
26
30
 
27
31
  it "exposes params with indifferent hash" do
28
32
  mock_app {
29
33
  get '/:foo' do
30
- assert_equal 'bar', params['foo']
31
- assert_equal 'bar', params[:foo]
34
+ params['foo'].should.equal 'bar'
35
+ params[:foo].should.equal 'bar'
32
36
  'well, alright'
33
37
  end
34
38
  }
35
39
  get '/bar'
36
- assert_equal 'well, alright', body
40
+ body.should.equal 'well, alright'
37
41
  end
38
42
 
39
43
  it "merges named params and query string params in params" do
40
44
  mock_app {
41
45
  get '/:foo' do
42
- assert_equal 'bar', params['foo']
43
- assert_equal 'biz', params['baz']
46
+ params['foo'].should.equal 'bar'
47
+ params['baz'].should.equal 'biz'
44
48
  end
45
49
  }
46
50
  get '/bar?baz=biz'
47
- assert ok?
51
+ should.be.ok
48
52
  end
49
53
 
50
54
  it "supports named params like /hello/:person" do
@@ -54,7 +58,7 @@ describe "Routing" do
54
58
  end
55
59
  }
56
60
  get '/hello/Frank'
57
- assert_equal 'Hello Frank', body
61
+ body.should.equal 'Hello Frank'
58
62
  end
59
63
 
60
64
  it "supports optional named params like /?:foo?/?:bar?" do
@@ -65,115 +69,58 @@ describe "Routing" do
65
69
  }
66
70
 
67
71
  get '/hello/world'
68
- assert ok?
69
- assert_equal "foo=hello;bar=world", body
72
+ should.be.ok
73
+ body.should.equal "foo=hello;bar=world"
70
74
 
71
75
  get '/hello'
72
- assert ok?
73
- assert_equal "foo=hello;bar=", body
76
+ should.be.ok
77
+ body.should.equal "foo=hello;bar="
74
78
 
75
79
  get '/'
76
- assert ok?
77
- assert_equal "foo=;bar=", body
80
+ should.be.ok
81
+ body.should.equal "foo=;bar="
78
82
  end
79
83
 
80
84
  it "supports single splat params like /*" do
81
85
  mock_app {
82
86
  get '/*' do
83
- assert params['splat'].kind_of?(Array)
87
+ params['splat'].should.be.kind_of Array
84
88
  params['splat'].join "\n"
85
89
  end
86
90
  }
87
91
 
88
92
  get '/foo'
89
- assert_equal "foo", body
93
+ body.should.equal "foo"
90
94
 
91
95
  get '/foo/bar/baz'
92
- assert_equal "foo/bar/baz", body
96
+ body.should.equal "foo/bar/baz"
93
97
  end
94
98
 
95
99
  it "supports mixing multiple splat params like /*/foo/*/*" do
96
100
  mock_app {
97
101
  get '/*/foo/*/*' do
98
- assert params['splat'].kind_of?(Array)
102
+ params['splat'].should.be.kind_of Array
99
103
  params['splat'].join "\n"
100
104
  end
101
105
  }
102
106
 
103
107
  get '/bar/foo/bling/baz/boom'
104
- assert_equal "bar\nbling\nbaz/boom", body
108
+ body.should.equal "bar\nbling\nbaz/boom"
105
109
 
106
110
  get '/bar/foo/baz'
107
- assert not_found?
111
+ should.be.not_found
108
112
  end
109
113
 
110
114
  it "supports mixing named and splat params like /:foo/*" do
111
115
  mock_app {
112
116
  get '/:foo/*' do
113
- assert_equal 'foo', params['foo']
114
- assert_equal ['bar/baz'], params['splat']
117
+ params['foo'].should.equal 'foo'
118
+ params['splat'].should.equal ['bar/baz']
115
119
  end
116
120
  }
117
121
 
118
122
  get '/foo/bar/baz'
119
- assert ok?
120
- end
121
-
122
- it "supports basic nested params" do
123
- mock_app {
124
- get '/hi' do
125
- params["person"]["name"]
126
- end
127
- }
128
-
129
- get "/hi?person[name]=John+Doe"
130
- assert ok?
131
- assert_equal "John Doe", body
132
- end
133
-
134
- it "exposes nested params with indifferent hash" do
135
- mock_app {
136
- get '/testme' do
137
- assert_equal 'baz', params['bar']['foo']
138
- assert_equal 'baz', params['bar'][:foo]
139
- 'well, alright'
140
- end
141
- }
142
- get '/testme?bar[foo]=baz'
143
- assert_equal 'well, alright', body
144
- end
145
-
146
- it "supports deeply nested params" do
147
- input = {
148
- 'browser[chrome][engine][name]' => 'V8',
149
- 'browser[chrome][engine][version]' => '1.0',
150
- 'browser[firefox][engine][name]' => 'spidermonkey',
151
- 'browser[firefox][engine][version]' => '1.7.0',
152
- 'emacs[map][goto-line]' => 'M-g g',
153
- 'emacs[version]' => '22.3.1',
154
- 'paste[name]' => 'hello world',
155
- 'paste[syntax]' => 'ruby'
156
- }
157
- expected = {
158
- "emacs" => {
159
- "map" => { "goto-line" => "M-g g" },
160
- "version" => "22.3.1"
161
- },
162
- "browser" => {
163
- "firefox" => {"engine" => {"name"=>"spidermonkey", "version"=>"1.7.0"}},
164
- "chrome" => {"engine" => {"name"=>"V8", "version"=>"1.0"}}
165
- },
166
- "paste" => {"name"=>"hello world", "syntax"=>"ruby"}
167
- }
168
- mock_app {
169
- get '/foo' do
170
- assert_equal expected, params
171
- 'looks good'
172
- end
173
- }
174
- get "/foo?#{param_string(input)}"
175
- assert ok?
176
- assert_equal 'looks good', body
123
+ should.be.ok
177
124
  end
178
125
 
179
126
  it "supports paths that include spaces" do
@@ -184,21 +131,21 @@ describe "Routing" do
184
131
  }
185
132
 
186
133
  get '/path%20with%20spaces'
187
- assert ok?
188
- assert_equal 'looks good', body
134
+ should.be.ok
135
+ body.should.equal 'looks good'
189
136
  end
190
137
 
191
138
  it "URL decodes named parameters and splats" do
192
139
  mock_app {
193
140
  get '/:foo/*' do
194
- assert_equal 'hello world', params['foo']
195
- assert_equal ['how are you'], params['splat']
141
+ params['foo'].should.equal 'hello world'
142
+ params['splat'].should.equal ['how are you']
196
143
  nil
197
144
  end
198
145
  }
199
146
 
200
147
  get '/hello%20world/how%20are%20you'
201
- assert ok?
148
+ should.be.ok
202
149
  end
203
150
 
204
151
  it 'supports regular expressions' do
@@ -209,21 +156,21 @@ describe "Routing" do
209
156
  }
210
157
 
211
158
  get '/foooom/bar'
212
- assert ok?
213
- assert_equal 'Hello World', body
159
+ should.be.ok
160
+ body.should.equal 'Hello World'
214
161
  end
215
162
 
216
163
  it 'makes regular expression captures available in params[:captures]' do
217
164
  mock_app {
218
165
  get(/^\/fo(.*)\/ba(.*)/) do
219
- assert_equal ['orooomma', 'f'], params[:captures]
166
+ params[:captures].should.equal ['orooomma', 'f']
220
167
  'right on'
221
168
  end
222
169
  }
223
170
 
224
171
  get '/foorooomma/baf'
225
- assert ok?
226
- assert_equal 'right on', body
172
+ should.be.ok
173
+ body.should.equal 'right on'
227
174
  end
228
175
 
229
176
  it "returns response immediately on halt" do
@@ -235,8 +182,8 @@ describe "Routing" do
235
182
  }
236
183
 
237
184
  get '/'
238
- assert ok?
239
- assert_equal 'Hello World', body
185
+ should.be.ok
186
+ body.should.equal 'Hello World'
240
187
  end
241
188
 
242
189
  it "transitions to the next matching route on pass" do
@@ -247,14 +194,14 @@ describe "Routing" do
247
194
  end
248
195
 
249
196
  get '/*' do
250
- assert !params.include?('foo')
197
+ params.should.not.include 'foo'
251
198
  'Hello World'
252
199
  end
253
200
  }
254
201
 
255
202
  get '/bar'
256
- assert ok?
257
- assert_equal 'Hello World', body
203
+ should.be.ok
204
+ body.should.equal 'Hello World'
258
205
  end
259
206
 
260
207
  it "transitions to 404 when passed and no subsequent route matches" do
@@ -266,7 +213,7 @@ describe "Routing" do
266
213
  }
267
214
 
268
215
  get '/bar'
269
- assert not_found?
216
+ should.be.not_found
270
217
  end
271
218
 
272
219
  it "passes when matching condition returns false" do
@@ -278,11 +225,11 @@ describe "Routing" do
278
225
  }
279
226
 
280
227
  get '/bar'
281
- assert ok?
282
- assert_equal 'Hello World', body
228
+ should.be.ok
229
+ body.should.equal 'Hello World'
283
230
 
284
231
  get '/foo'
285
- assert not_found?
232
+ should.be.not_found
286
233
  end
287
234
 
288
235
  it "does not pass when matching condition returns nil" do
@@ -294,8 +241,8 @@ describe "Routing" do
294
241
  }
295
242
 
296
243
  get '/bar'
297
- assert ok?
298
- assert_equal 'Hello World', body
244
+ should.be.ok
245
+ body.should.equal 'Hello World'
299
246
  end
300
247
 
301
248
  it "passes to next route when condition calls pass explicitly" do
@@ -307,11 +254,11 @@ describe "Routing" do
307
254
  }
308
255
 
309
256
  get '/bar'
310
- assert ok?
311
- assert_equal 'Hello World', body
257
+ should.be.ok
258
+ body.should.equal 'Hello World'
312
259
 
313
260
  get '/foo'
314
- assert not_found?
261
+ should.be.not_found
315
262
  end
316
263
 
317
264
  it "passes to the next route when host_name does not match" do
@@ -322,70 +269,37 @@ describe "Routing" do
322
269
  end
323
270
  }
324
271
  get '/foo'
325
- assert not_found?
272
+ should.be.not_found
326
273
 
327
274
  get '/foo', :env => { 'HTTP_HOST' => 'example.com' }
328
- assert_equal 200, status
329
- assert_equal 'Hello World', body
275
+ status.should.equal 200
276
+ body.should.equal 'Hello World'
330
277
  end
331
278
 
332
279
  it "passes to the next route when user_agent does not match" do
333
280
  mock_app {
334
- user_agent(/Foo/)
281
+ user_agent /Foo/
335
282
  get '/foo' do
336
283
  'Hello World'
337
284
  end
338
285
  }
339
286
  get '/foo'
340
- assert not_found?
287
+ should.be.not_found
341
288
 
342
289
  get '/foo', :env => { 'HTTP_USER_AGENT' => 'Foo Bar' }
343
- assert_equal 200, status
344
- assert_equal 'Hello World', body
290
+ status.should.equal 200
291
+ body.should.equal 'Hello World'
345
292
  end
346
293
 
347
294
  it "makes captures in user agent pattern available in params[:agent]" do
348
295
  mock_app {
349
- user_agent(/Foo (.*)/)
296
+ user_agent /Foo (.*)/
350
297
  get '/foo' do
351
298
  'Hello ' + params[:agent].first
352
299
  end
353
300
  }
354
301
  get '/foo', :env => { 'HTTP_USER_AGENT' => 'Foo Bar' }
355
- assert_equal 200, status
356
- assert_equal 'Hello Bar', body
357
- end
358
-
359
- it "filters by accept header" do
360
- mock_app {
361
- get '/', :provides => :xml do
362
- request.env['HTTP_ACCEPT']
363
- end
364
- }
365
-
366
- get '/', :env => { :accept => 'application/xml' }
367
- assert ok?
368
- assert_equal 'application/xml', body
369
- assert_equal 'application/xml', response.headers['Content-Type']
370
-
371
- get '/', :env => { :accept => 'text/html' }
372
- assert !ok?
373
- end
374
-
375
- it "allows multiple mime types for accept header" do
376
- types = ['image/jpeg', 'image/pjpeg']
377
-
378
- mock_app {
379
- get '/', :provides => types do
380
- request.env['HTTP_ACCEPT']
381
- end
382
- }
383
-
384
- types.each do |type|
385
- get '/', :env => { :accept => type }
386
- assert ok?
387
- assert_equal type, body
388
- assert_equal type, response.headers['Content-Type']
389
- end
302
+ status.should.equal 200
303
+ body.should.equal 'Hello Bar'
390
304
  end
391
305
  end