goliath 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of goliath might be problematic. Click here for more details.

Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/examples/rasterize/rasterize.rb +1 -1
  3. data/goliath.gemspec +1 -0
  4. data/lib/goliath/connection.rb +16 -12
  5. data/lib/goliath/constants.rb +1 -0
  6. data/lib/goliath/rack/default_response_format.rb +3 -9
  7. data/lib/goliath/rack/formatters/json.rb +1 -1
  8. data/lib/goliath/rack/params.rb +1 -1
  9. data/lib/goliath/rack/templates.rb +1 -1
  10. data/lib/goliath/request.rb +35 -18
  11. data/lib/goliath/response.rb +3 -1
  12. data/lib/goliath/server.rb +1 -1
  13. data/lib/goliath/version.rb +1 -1
  14. data/spec/integration/async_request_processing.rb +2 -2
  15. data/spec/integration/chunked_streaming_spec.rb +1 -1
  16. data/spec/integration/early_abort_spec.rb +5 -5
  17. data/spec/integration/echo_spec.rb +7 -7
  18. data/spec/integration/empty_body_spec.rb +2 -2
  19. data/spec/integration/event_stream_spec.rb +3 -3
  20. data/spec/integration/exception_handling_spec.rb +16 -16
  21. data/spec/integration/http_log_spec.rb +16 -16
  22. data/spec/integration/jsonp_spec.rb +6 -6
  23. data/spec/integration/keepalive_spec.rb +2 -2
  24. data/spec/integration/pipelining_spec.rb +3 -3
  25. data/spec/integration/reloader_spec.rb +3 -3
  26. data/spec/integration/template_spec.rb +7 -7
  27. data/spec/integration/test_helper_spec.rb +3 -3
  28. data/spec/integration/trace_spec.rb +2 -2
  29. data/spec/integration/valid_spec.rb +8 -8
  30. data/spec/integration/websocket_spec.rb +2 -2
  31. data/spec/spec_helper.rb +1 -3
  32. data/spec/unit/api_spec.rb +1 -1
  33. data/spec/unit/connection_spec.rb +8 -8
  34. data/spec/unit/console_spec.rb +3 -3
  35. data/spec/unit/env_spec.rb +9 -9
  36. data/spec/unit/headers_spec.rb +8 -8
  37. data/spec/unit/rack/default_mime_type_spec.rb +3 -3
  38. data/spec/unit/rack/formatters/json_spec.rb +35 -13
  39. data/spec/unit/rack/formatters/plist_spec.rb +8 -8
  40. data/spec/unit/rack/formatters/xml_spec.rb +18 -18
  41. data/spec/unit/rack/formatters/yaml_spec.rb +13 -13
  42. data/spec/unit/rack/heartbeat_spec.rb +15 -15
  43. data/spec/unit/rack/params_spec.rb +62 -60
  44. data/spec/unit/rack/render_spec.rb +14 -14
  45. data/spec/unit/rack/validation/boolean_value_spec.rb +6 -6
  46. data/spec/unit/rack/validation/default_params_spec.rb +13 -13
  47. data/spec/unit/rack/validation/numeric_range_spec.rb +17 -17
  48. data/spec/unit/rack/validation/param_spec.rb +75 -75
  49. data/spec/unit/rack/validation/request_method_spec.rb +9 -9
  50. data/spec/unit/rack/validation/required_param_spec.rb +28 -28
  51. data/spec/unit/rack/validation/required_value_spec.rb +19 -19
  52. data/spec/unit/request_spec.rb +18 -18
  53. data/spec/unit/response_spec.rb +6 -6
  54. data/spec/unit/runner_spec.rb +31 -31
  55. data/spec/unit/server_spec.rb +21 -21
  56. data/spec/unit/validation/standard_http_errors_spec.rb +6 -6
  57. metadata +20 -7
@@ -9,7 +9,7 @@ describe Goliath::Rack::Validation::NumericRange do
9
9
 
10
10
  it 'accepts options on create' do
11
11
  opts = { :min => 1, :key => 2 }
12
- lambda { Goliath::Rack::Validation::NumericRange.new('my app', opts) }.should_not raise_error
12
+ expect { Goliath::Rack::Validation::NumericRange.new('my app', opts) }.not_to raise_error
13
13
  end
14
14
 
15
15
  describe 'with middleware' do
@@ -20,41 +20,41 @@ describe Goliath::Rack::Validation::NumericRange do
20
20
  it 'uses the default if value is less then min' do
21
21
  @env['params']['id'] = -10
22
22
  @nr.call(@env)
23
- @env['params']['id'].should == 15
23
+ expect(@env['params']['id']).to eq(15)
24
24
  end
25
25
 
26
26
  it 'uses the default if value is greater then max' do
27
27
  @env['params']['id'] = 25
28
28
  @nr.call(@env)
29
- @env['params']['id'].should == 15
29
+ expect(@env['params']['id']).to eq(15)
30
30
  end
31
31
 
32
32
  it 'uses the first value, if the value is an array' do
33
33
  @env['params']['id'] = [10, 11, 12]
34
34
  @nr.call(@env)
35
- @env['params']['id'].should == 10
35
+ expect(@env['params']['id']).to eq(10)
36
36
  end
37
37
 
38
38
  it 'uses the default if value is not present' do
39
39
  @nr.call(@env)
40
- @env['params']['id'].should == 15
40
+ expect(@env['params']['id']).to eq(15)
41
41
  end
42
42
 
43
43
  it 'uses the default if value is nil' do
44
44
  @env['params']['id'] = nil
45
45
  @nr.call(@env)
46
- @env['params']['id'].should == 15
46
+ expect(@env['params']['id']).to eq(15)
47
47
  end
48
48
 
49
49
  it 'returns the app status, headers and body' do
50
50
  app_headers = {'Content-Type' => 'app'}
51
51
  app_body = {'b' => 'c'}
52
- @app.should_receive(:call).and_return([200, app_headers, app_body])
52
+ expect(@app).to receive(:call).and_return([200, app_headers, app_body])
53
53
 
54
54
  status, headers, body = @nr.call(@env)
55
- status.should == 200
56
- headers.should == app_headers
57
- body.should == app_body
55
+ expect(status).to eq(200)
56
+ expect(headers).to eq(app_headers)
57
+ expect(body).to eq(app_body)
58
58
  end
59
59
  end
60
60
 
@@ -62,42 +62,42 @@ describe Goliath::Rack::Validation::NumericRange do
62
62
  nr = Goliath::Rack::Validation::NumericRange.new(@app, {:key => 'id', :min => 1.1, :as => Float})
63
63
  @env['params']['id'] = 1.5
64
64
  nr.call(@env)
65
- @env['params']['id'].should == 1.5
65
+ expect(@env['params']['id']).to eq(1.5)
66
66
  end
67
67
 
68
68
  it 'raises error if key is not set' do
69
- lambda { Goliath::Rack::Validation::NumericRange.new('app', {:min => 5}) }.should raise_error('NumericRange key required')
69
+ expect { Goliath::Rack::Validation::NumericRange.new('app', {:min => 5}) }.to raise_error('NumericRange key required')
70
70
  end
71
71
 
72
72
  it 'raises error if neither min nor max set' do
73
- lambda { Goliath::Rack::Validation::NumericRange.new('app', {:key => 5}) }.should raise_error('NumericRange requires :min or :max')
73
+ expect { Goliath::Rack::Validation::NumericRange.new('app', {:key => 5}) }.to raise_error('NumericRange requires :min or :max')
74
74
  end
75
75
 
76
76
  it 'uses min if default not set' do
77
77
  nr = Goliath::Rack::Validation::NumericRange.new(@app, {:key => 'id', :min => 5, :max => 10})
78
78
  @env['params']['id'] = 15
79
79
  nr.call(@env)
80
- @env['params']['id'].should == 5
80
+ expect(@env['params']['id']).to eq(5)
81
81
  end
82
82
 
83
83
  it 'uses max if default and min not set' do
84
84
  nr = Goliath::Rack::Validation::NumericRange.new(@app, {:key => 'id', :max => 10})
85
85
  @env['params']['id'] = 15
86
86
  nr.call(@env)
87
- @env['params']['id'].should == 10
87
+ expect(@env['params']['id']).to eq(10)
88
88
  end
89
89
 
90
90
  it "doesn't require min" do
91
91
  nr = Goliath::Rack::Validation::NumericRange.new(@app, {:key => 'id', :max => 10})
92
92
  @env['params']['id'] = 8
93
93
  nr.call(@env)
94
- @env['params']['id'].should == 8
94
+ expect(@env['params']['id']).to eq(8)
95
95
  end
96
96
 
97
97
  it "doesn't require max" do
98
98
  nr = Goliath::Rack::Validation::NumericRange.new(@app, {:key => 'id', :min => 1})
99
99
  @env['params']['id'] = 15
100
100
  nr.call(@env)
101
- @env['params']['id'].should == 15
101
+ expect(@env['params']['id']).to eq(15)
102
102
  end
103
103
  end
@@ -8,39 +8,39 @@ describe Goliath::Rack::Validation::Param do
8
8
  end
9
9
 
10
10
  it "should not allow invalid options" do
11
- lambda {
11
+ expect {
12
12
  Goliath::Rack::Validation::Param.new(@app, {:key => 'user', :as => Class.new})
13
- }.should raise_error(Exception)
13
+ }.to raise_error(Exception)
14
14
  end
15
15
 
16
16
  it "raises if key is not supplied" do
17
- lambda {
17
+ expect {
18
18
  Goliath::Rack::Validation::Param.new(@app)
19
- }.should raise_error(Exception)
19
+ }.to raise_error(Exception)
20
20
  end
21
21
 
22
22
  it "uses a default value if optional is not supplied" do
23
23
  cv = Goliath::Rack::Validation::Param.new(@app, :key => 'key')
24
- cv.optional.should be false
24
+ expect(cv.optional).to be false
25
25
  end
26
26
 
27
27
  it "should have default and message be optional" do
28
28
  cv = nil
29
- lambda {
29
+ expect {
30
30
  cv = Goliath::Rack::Validation::Param.new(@app, {:key => 'flag',
31
31
  :as => Goliath::Rack::Types::Boolean})
32
- }.should_not raise_error
32
+ }.not_to raise_error
33
33
 
34
- cv.default.should be_nil
35
- cv.message.should_not be_nil
34
+ expect(cv.default).to be_nil
35
+ expect(cv.message).not_to be_nil
36
36
  end
37
37
 
38
38
  it "should fail if given an invalid option" do
39
39
  cv = nil
40
- lambda {
40
+ expect {
41
41
  cv = Goliath::Rack::Validation::Param.new(@app, {:key => 'flag',
42
42
  :as => Goliath::Rack::Types::Boolean, :animal => :monkey})
43
- }.should raise_error('Unknown options: {:animal=>:monkey}')
43
+ }.to raise_error('Unknown options: {:animal=>:monkey}')
44
44
  end
45
45
 
46
46
  context "fetch_key" do
@@ -57,7 +57,7 @@ describe Goliath::Rack::Validation::Param do
57
57
  }
58
58
  }
59
59
  }
60
- @cv.fetch_key(params).should == "mike"
60
+ expect(@cv.fetch_key(params)).to eq("mike")
61
61
  end
62
62
 
63
63
  it "should return nil given an incorrect params" do
@@ -68,7 +68,7 @@ describe Goliath::Rack::Validation::Param do
68
68
  }
69
69
  }
70
70
  }
71
- @cv.fetch_key(params).should be_nil
71
+ expect(@cv.fetch_key(params)).to be_nil
72
72
  end
73
73
 
74
74
  it "should set value if given" do
@@ -79,8 +79,8 @@ describe Goliath::Rack::Validation::Param do
79
79
  }
80
80
  }
81
81
  }
82
- @cv.fetch_key(params, "tim").should == "tim"
83
- params['data']['credentials']['login'].should == "tim"
82
+ expect(@cv.fetch_key(params, "tim")).to eq("tim")
83
+ expect(params['data']['credentials']['login']).to eq("tim")
84
84
  end
85
85
  end
86
86
 
@@ -88,9 +88,9 @@ describe Goliath::Rack::Validation::Param do
88
88
 
89
89
  it 'defaults type and message' do
90
90
  @rp = Goliath::Rack::Validation::Param.new('app', :key => 'key')
91
- @rp.type.should_not be_nil
92
- @rp.type.should_not =~ /^\s*$/
93
- @rp.message.should == 'identifier missing'
91
+ expect(@rp.type).not_to be_nil
92
+ expect(@rp.type).not_to match(/^\s*$/)
93
+ expect(@rp.message).to eq('identifier missing')
94
94
  end
95
95
 
96
96
 
@@ -103,76 +103,76 @@ describe Goliath::Rack::Validation::Param do
103
103
  end
104
104
 
105
105
  it 'stores type and key options' do
106
- @rp.type.should == 'Monkey'
107
- @rp.key.should == 'mk'
106
+ expect(@rp.type).to eq('Monkey')
107
+ expect(@rp.key).to eq('mk')
108
108
  end
109
109
 
110
110
  it 'calls validation_error with a custom message' do
111
- @rp.should_receive(:validation_error).with(anything, 'Monkey is required')
111
+ expect(@rp).to receive(:validation_error).with(anything, 'Monkey is required')
112
112
  @rp.call(@env)
113
113
  end
114
114
 
115
115
  it 'returns the app status, headers and body' do
116
116
  app_headers = {'Content-Type' => 'app'}
117
117
  app_body = {'b' => 'c'}
118
- @app.should_receive(:call).and_return([201, app_headers, app_body])
118
+ expect(@app).to receive(:call).and_return([201, app_headers, app_body])
119
119
 
120
120
  @env['params']['mk'] = 'monkey'
121
121
 
122
122
  status, headers, body = @rp.call(@env)
123
- status.should == 201
124
- headers.should == app_headers
125
- body.should == app_body
123
+ expect(status).to eq(201)
124
+ expect(headers).to eq(app_headers)
125
+ expect(body).to eq(app_body)
126
126
  end
127
127
 
128
128
  context 'key_valid?' do
129
129
  it 'raises exception if the key is not provided' do
130
- @rp.key_valid?(@env['params']).should be false
130
+ expect(@rp.key_valid?(@env['params'])).to be false
131
131
  end
132
132
 
133
133
  it 'raises exception if the key is blank' do
134
134
  @env['params']['mk'] = ''
135
- @rp.key_valid?(@env['params']).should be false
135
+ expect(@rp.key_valid?(@env['params'])).to be false
136
136
  end
137
137
 
138
138
  it 'raises exception if the key is nil' do
139
139
  @env['params']['mk'] = nil
140
- @rp.key_valid?(@env['params']).should be false
140
+ expect(@rp.key_valid?(@env['params'])).to be false
141
141
  end
142
142
 
143
143
  it 'handles an empty array' do
144
144
  @env['params']['mk'] = []
145
- @rp.key_valid?(@env['params']).should be false
145
+ expect(@rp.key_valid?(@env['params'])).to be false
146
146
  end
147
147
 
148
148
  it 'handles an array of nils' do
149
149
  @env['params']['mk'] = [nil, nil, nil]
150
- @rp.key_valid?(@env['params']).should be false
150
+ expect(@rp.key_valid?(@env['params'])).to be false
151
151
  end
152
152
 
153
153
  it 'handles an array of blanks' do
154
154
  @env['params']['mk'] = ['', '', '']
155
- @rp.key_valid?(@env['params']).should be false
155
+ expect(@rp.key_valid?(@env['params'])).to be false
156
156
  end
157
157
 
158
158
  it "doesn't raise if the key provided" do
159
159
  @env['params']['mk'] = 'my value'
160
- @rp.key_valid?(@env['params']).should be true
160
+ expect(@rp.key_valid?(@env['params'])).to be true
161
161
  end
162
162
 
163
163
  it "doesn't raise if the array contains valid data" do
164
164
  @env['params']['mk'] = [1, 2, 3, 4]
165
- @rp.key_valid?(@env['params']).should be true
165
+ expect(@rp.key_valid?(@env['params'])).to be true
166
166
  end
167
167
 
168
168
  it "doesn't raise if the key provided is multiline and has blanks" do
169
169
  @env['params']['mk'] = "my\n \nvalue"
170
- @rp.key_valid?(@env['params']).should be true
170
+ expect(@rp.key_valid?(@env['params'])).to be true
171
171
  end
172
172
 
173
173
  it "doesn't raise if the key provided is an array and contains multiline with blanks" do
174
174
  @env['params']['mk'] = ["my\n \nvalue", "my\n \nother\n \nvalue"]
175
- @rp.key_valid?(@env['params']).should be true
175
+ expect(@rp.key_valid?(@env['params'])).to be true
176
176
  end
177
177
  end
178
178
  end
@@ -194,7 +194,7 @@ describe Goliath::Rack::Validation::Param do
194
194
  }
195
195
  }
196
196
 
197
- @rp.key_valid?(@env['params']).should be false
197
+ expect(@rp.key_valid?(@env['params'])).to be false
198
198
  end
199
199
 
200
200
  it "return true if key is present" do
@@ -205,7 +205,7 @@ describe Goliath::Rack::Validation::Param do
205
205
  }
206
206
  }
207
207
 
208
- @rp.key_valid?(@env['params']).should be true
208
+ expect(@rp.key_valid?(@env['params'])).to be true
209
209
  end
210
210
  end
211
211
 
@@ -225,7 +225,7 @@ describe Goliath::Rack::Validation::Param do
225
225
  }
226
226
  }
227
227
 
228
- @rp.key_valid?(@env['params']).should be false
228
+ expect(@rp.key_valid?(@env['params'])).to be false
229
229
  end
230
230
 
231
231
  it "return true if key is present" do
@@ -236,7 +236,7 @@ describe Goliath::Rack::Validation::Param do
236
236
  }
237
237
  }
238
238
 
239
- @rp.key_valid?(@env['params']).should be true
239
+ expect(@rp.key_valid?(@env['params'])).to be true
240
240
  end
241
241
  end
242
242
 
@@ -245,9 +245,9 @@ describe Goliath::Rack::Validation::Param do
245
245
  context "Coerce" do
246
246
 
247
247
  it "should only accept a class in the :as" do
248
- lambda {
248
+ expect {
249
249
  Goliath::Rack::Validation::Param.new(@app, {:key => 'user', :as => "not a class"})
250
- }.should raise_error('Params as must be a class')
250
+ }.to raise_error('Params as must be a class')
251
251
  end
252
252
 
253
253
  context 'with middleware' do
@@ -266,7 +266,7 @@ describe Goliath::Rack::Validation::Param do
266
266
  @env['params']['user'] = value.first
267
267
  cv = Goliath::Rack::Validation::Param.new(@app, {:key => 'user', :as => type})
268
268
  cv.call(@env)
269
- @env['params']['user'].should == value[1]
269
+ expect(@env['params']['user']).to eq(value[1])
270
270
  end
271
271
  end
272
272
  end
@@ -282,9 +282,9 @@ describe Goliath::Rack::Validation::Param do
282
282
  @env['params']['user'] = value
283
283
  cv = Goliath::Rack::Validation::Param.new(@app, {:key => 'user', :as => type})
284
284
  result = cv.call(@env)
285
- result.should be_an_instance_of(Array)
286
- result.first.should == 400
287
- result.last.should have_key(:error)
285
+ expect(result).to be_an_instance_of(Array)
286
+ expect(result.first).to eq(400)
287
+ expect(result.last).to have_key(:error)
288
288
  end
289
289
  end
290
290
  end
@@ -292,10 +292,10 @@ describe Goliath::Rack::Validation::Param do
292
292
  it "should not fail with a invalid input, given a default value" do
293
293
  cv = nil
294
294
  @env['params']['user'] = "boo"
295
- lambda {
295
+ expect {
296
296
  cv = Goliath::Rack::Validation::Param.new(@app, {:key => 'user',
297
297
  :as => Goliath::Rack::Types::Boolean , :default => 'default'})
298
- }.should_not raise_error
298
+ }.not_to raise_error
299
299
  @env['params']['user'] = 'default'
300
300
  end
301
301
 
@@ -305,10 +305,10 @@ describe Goliath::Rack::Validation::Param do
305
305
  :as => Goliath::Rack::Types::Integer, :message => "custom message"})
306
306
 
307
307
  result = cv.call(@env)
308
- result.should be_an_instance_of(Array)
309
- result.first.should == 400
310
- result.last.should have_key(:error)
311
- result.last[:error].should == "custom message"
308
+ expect(result).to be_an_instance_of(Array)
309
+ expect(result.first).to eq(400)
310
+ expect(result.last).to have_key(:error)
311
+ expect(result.last[:error]).to eq("custom message")
312
312
  end
313
313
  end
314
314
 
@@ -320,15 +320,15 @@ describe Goliath::Rack::Validation::Param do
320
320
  :as => Goliath::Rack::Types::Integer
321
321
  @env['params']['login'] = "3"
322
322
  cv.call(@env)
323
- @env['params']['login'].should == 3
323
+ expect(@env['params']['login']).to eq(3)
324
324
 
325
325
  @env['params']['login'] = nil
326
326
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login",
327
327
  :as => Goliath::Rack::Types::Integer
328
328
  result = cv.call(@env)
329
- result.should be_an_instance_of(Array)
330
- result.first.should == 400
331
- result.last.should have_key(:error)
329
+ expect(result).to be_an_instance_of(Array)
330
+ expect(result.first).to eq(400)
331
+ expect(result.last).to have_key(:error)
332
332
  end
333
333
 
334
334
  it "should do required param + coerce (nested)" do
@@ -337,30 +337,30 @@ describe Goliath::Rack::Validation::Param do
337
337
  @env['params']['login'] = {}
338
338
  @env['params']['login']['other'] = "3"
339
339
  cv.call(@env)
340
- @env['params']['login']['other'].should == 3
340
+ expect(@env['params']['login']['other']).to eq(3)
341
341
 
342
342
  @env['params']['login'] = {}
343
343
  @env['params']['login']['other'] = nil
344
344
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login.other",
345
345
  :as => Goliath::Rack::Types::Integer
346
346
  result = cv.call(@env)
347
- result.should be_an_instance_of(Array)
348
- result.first.should == 400
349
- result.last.should have_key(:error)
347
+ expect(result).to be_an_instance_of(Array)
348
+ expect(result.first).to eq(400)
349
+ expect(result.last).to have_key(:error)
350
350
  end
351
351
 
352
352
  it "should do required param + not coerce (not nested)" do
353
353
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login"
354
354
  @env['params']['login'] = "3"
355
355
  cv.call(@env)
356
- @env['params']['login'].should == "3"
356
+ expect(@env['params']['login']).to eq("3")
357
357
 
358
358
  @env['params']['login'] = nil
359
359
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login"
360
360
  result = cv.call(@env)
361
- result.should be_an_instance_of(Array)
362
- result.first.should == 400
363
- result.last.should have_key(:error)
361
+ expect(result).to be_an_instance_of(Array)
362
+ expect(result.first).to eq(400)
363
+ expect(result.last).to have_key(:error)
364
364
  end
365
365
 
366
366
  it "should do required param + not coerce (nested)" do
@@ -368,15 +368,15 @@ describe Goliath::Rack::Validation::Param do
368
368
  @env['params']['login'] = {}
369
369
  @env['params']['login']['other'] = "3"
370
370
  cv.call(@env)
371
- @env['params']['login']['other'].should == "3"
371
+ expect(@env['params']['login']['other']).to eq("3")
372
372
 
373
373
  @env['params']['login'] = {}
374
374
  @env['params']['login']['other'] = nil
375
375
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login.other"
376
376
  result = cv.call(@env)
377
- result.should be_an_instance_of(Array)
378
- result.first.should == 400
379
- result.last.should have_key(:error)
377
+ expect(result).to be_an_instance_of(Array)
378
+ expect(result.first).to eq(400)
379
+ expect(result.last).to have_key(:error)
380
380
  end
381
381
 
382
382
  it "should do optional param + coerce (not nested)" do
@@ -384,13 +384,13 @@ describe Goliath::Rack::Validation::Param do
384
384
  :as => Goliath::Rack::Types::Integer, :optional => true
385
385
  @env['params']['login'] = "3"
386
386
  cv.call(@env)
387
- @env['params']['login'].should == 3
387
+ expect(@env['params']['login']).to eq(3)
388
388
 
389
389
  @env['params']['login'] = nil
390
390
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login",
391
391
  :as => Goliath::Rack::Types::Integer, :optional => true
392
392
  result = cv.call(@env)
393
- result.should_not be_an_instance_of(Array) #implying its OK
393
+ expect(result).not_to be_an_instance_of(Array) #implying its OK
394
394
  end
395
395
 
396
396
  it "should do optional param + coerce (nested)" do
@@ -399,14 +399,14 @@ describe Goliath::Rack::Validation::Param do
399
399
  @env['params']['login'] = {}
400
400
  @env['params']['login']['other'] = "3"
401
401
  cv.call(@env)
402
- @env['params']['login']['other'].should == 3
402
+ expect(@env['params']['login']['other']).to eq(3)
403
403
 
404
404
  @env['params']['login'] = {}
405
405
  @env['params']['login']['other'] = nil
406
406
  cv = Goliath::Rack::Validation::Param.new @app, :key => ['login', 'other'],
407
407
  :as => Goliath::Rack::Types::Integer, :optional => true
408
408
  result = cv.call(@env)
409
- result.should_not be_an_instance_of(Array) #implying its OK
409
+ expect(result).not_to be_an_instance_of(Array) #implying its OK
410
410
  end
411
411
 
412
412
  it "should do optional param and not coerce (not nested)" do
@@ -414,13 +414,13 @@ describe Goliath::Rack::Validation::Param do
414
414
  :optional => true
415
415
  @env['params']['login'] = "3"
416
416
  cv.call(@env)
417
- @env['params']['login'].should == "3"
417
+ expect(@env['params']['login']).to eq("3")
418
418
 
419
419
  @env['params']['login'] = nil
420
420
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login",
421
421
  :optional => true
422
422
  result = cv.call(@env)
423
- result.should_not be_an_instance_of(Array) #implying its OK
423
+ expect(result).not_to be_an_instance_of(Array) #implying its OK
424
424
  end
425
425
 
426
426
  it "should do optional param and not coerce (nested)" do
@@ -429,14 +429,14 @@ describe Goliath::Rack::Validation::Param do
429
429
  @env['params']['login'] = {}
430
430
  @env['params']['login']['other'] = "3"
431
431
  cv.call(@env)
432
- @env['params']['login']['other'].should == "3"
432
+ expect(@env['params']['login']['other']).to eq("3")
433
433
 
434
434
  @env['params']['login'] = {}
435
435
  @env['params']['login']['other'] = nil
436
436
  cv = Goliath::Rack::Validation::Param.new @app, :key => "login.other",
437
437
  :optional => true
438
438
  result = cv.call(@env)
439
- result.should_not be_an_instance_of(Array) #implying its OK
439
+ expect(result).not_to be_an_instance_of(Array) #implying its OK
440
440
  end
441
441
  end
442
442
  end
@@ -7,11 +7,11 @@ describe Goliath::Rack::Validation::RequestMethod do
7
7
  @app_body = {'a' => 'b'}
8
8
 
9
9
  @app = double('app').as_null_object
10
- @app.stub(:call).and_return([200, @app_headers, @app_body])
10
+ allow(@app).to receive(:call).and_return([200, @app_headers, @app_body])
11
11
  end
12
12
 
13
13
  it 'accepts an app' do
14
- lambda { Goliath::Rack::Validation::RequestMethod.new('my app') }.should_not raise_error
14
+ expect { Goliath::Rack::Validation::RequestMethod.new('my app') }.not_to raise_error
15
15
  end
16
16
 
17
17
  describe 'with defaults' do
@@ -22,31 +22,31 @@ describe Goliath::Rack::Validation::RequestMethod do
22
22
 
23
23
  it 'raises error if method is invalid' do
24
24
  @env['REQUEST_METHOD'] = 'fubar'
25
- @rm.call(@env).should == [405, {'Allow' => 'GET, POST'}, {:error => "Invalid request method"}]
25
+ expect(@rm.call(@env)).to eq([405, {'Allow' => 'GET, POST'}, {:error => "Invalid request method"}])
26
26
  end
27
27
 
28
28
  it 'allows valid methods through' do
29
29
  @env['REQUEST_METHOD'] = 'GET'
30
- @rm.call(@env).should == [200, @app_headers, @app_body]
30
+ expect(@rm.call(@env)).to eq([200, @app_headers, @app_body])
31
31
  end
32
32
 
33
33
  it 'returns app status, headers and body' do
34
34
  @env['REQUEST_METHOD'] = 'POST'
35
35
 
36
36
  status, headers, body = @rm.call(@env)
37
- status.should == 200
38
- headers.should == @app_headers
39
- body.should == @app_body
37
+ expect(status).to eq(200)
38
+ expect(headers).to eq(@app_headers)
39
+ expect(body).to eq(@app_body)
40
40
  end
41
41
  end
42
42
 
43
43
  it 'accepts methods on initialize' do
44
44
  rm = Goliath::Rack::Validation::RequestMethod.new('my app', ['GET', 'DELETE', 'HEAD'])
45
- rm.methods.should == ['GET', 'DELETE', 'HEAD']
45
+ expect(rm.methods).to eq(['GET', 'DELETE', 'HEAD'])
46
46
  end
47
47
 
48
48
  it 'accepts string method on initialize' do
49
49
  rm = Goliath::Rack::Validation::RequestMethod.new('my app', 'GET')
50
- rm.methods.should == ['GET']
50
+ expect(rm.methods).to eq(['GET'])
51
51
  end
52
52
  end