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
@@ -3,23 +3,23 @@ require 'goliath/rack/validation/required_param'
3
3
 
4
4
  describe Goliath::Rack::Validation::RequiredParam do
5
5
  it 'accepts an app' do
6
- lambda { Goliath::Rack::Validation::RequiredParam.new('my app') }.should_not raise_error
6
+ expect { Goliath::Rack::Validation::RequiredParam.new('my app') }.not_to raise_error
7
7
  end
8
8
 
9
9
  it 'accepts options on create' do
10
10
  opts = { :type => 1, :key => 2, :message => 'is required' }
11
- lambda { Goliath::Rack::Validation::RequiredParam.new('my app', opts) }.should_not raise_error
11
+ expect { Goliath::Rack::Validation::RequiredParam.new('my app', opts) }.not_to raise_error
12
12
  end
13
13
 
14
14
  it 'defaults type, key and message' do
15
15
  @rp = Goliath::Rack::Validation::RequiredParam.new('app')
16
- @rp.key.should_not be_nil
17
- @rp.key.should_not =~ /^\s*$/
16
+ expect(@rp.key).not_to be_nil
17
+ expect(@rp.key).not_to match(/^\s*$/)
18
18
 
19
- @rp.type.should_not be_nil
20
- @rp.type.should_not =~ /^\s*$/
19
+ expect(@rp.type).not_to be_nil
20
+ expect(@rp.type).not_to match(/^\s*$/)
21
21
 
22
- @rp.message.should == 'identifier missing'
22
+ expect(@rp.message).to eq('identifier missing')
23
23
  end
24
24
 
25
25
  describe 'with middleware' do
@@ -30,76 +30,76 @@ describe Goliath::Rack::Validation::RequiredParam do
30
30
  end
31
31
 
32
32
  it 'stores type and key options' do
33
- @rp.type.should == 'Monkey'
34
- @rp.key.should == 'mk'
33
+ expect(@rp.type).to eq('Monkey')
34
+ expect(@rp.key).to eq('mk')
35
35
  end
36
36
 
37
37
  it 'calls validation_error with a custom message' do
38
- @rp.should_receive(:validation_error).with(anything, 'Monkey is required')
38
+ expect(@rp).to receive(:validation_error).with(anything, 'Monkey is required')
39
39
  @rp.call(@env)
40
40
  end
41
41
 
42
42
  it 'returns the app status, headers and body' do
43
43
  app_headers = {'Content-Type' => 'app'}
44
44
  app_body = {'b' => 'c'}
45
- @app.should_receive(:call).and_return([201, app_headers, app_body])
45
+ expect(@app).to receive(:call).and_return([201, app_headers, app_body])
46
46
 
47
47
  @env['params']['mk'] = 'monkey'
48
48
 
49
49
  status, headers, body = @rp.call(@env)
50
- status.should == 201
51
- headers.should == app_headers
52
- body.should == app_body
50
+ expect(status).to eq(201)
51
+ expect(headers).to eq(app_headers)
52
+ expect(body).to eq(app_body)
53
53
  end
54
54
 
55
55
  describe 'key_valid?' do
56
56
  it 'raises exception if the key is not provided' do
57
- @rp.key_valid?(@env['params']).should be false
57
+ expect(@rp.key_valid?(@env['params'])).to be false
58
58
  end
59
59
 
60
60
  it 'raises exception if the key is blank' do
61
61
  @env['params']['mk'] = ''
62
- @rp.key_valid?(@env['params']).should be false
62
+ expect(@rp.key_valid?(@env['params'])).to be false
63
63
  end
64
64
 
65
65
  it 'raises exception if the key is nil' do
66
66
  @env['params']['mk'] = nil
67
- @rp.key_valid?(@env['params']).should be false
67
+ expect(@rp.key_valid?(@env['params'])).to be false
68
68
  end
69
69
 
70
70
  it 'handles an empty array' do
71
71
  @env['params']['mk'] = []
72
- @rp.key_valid?(@env['params']).should be false
72
+ expect(@rp.key_valid?(@env['params'])).to be false
73
73
  end
74
74
 
75
75
  it 'handles an array of nils' do
76
76
  @env['params']['mk'] = [nil, nil, nil]
77
- @rp.key_valid?(@env['params']).should be false
77
+ expect(@rp.key_valid?(@env['params'])).to be false
78
78
  end
79
79
 
80
80
  it 'handles an array of blanks' do
81
81
  @env['params']['mk'] = ['', '', '']
82
- @rp.key_valid?(@env['params']).should be false
82
+ expect(@rp.key_valid?(@env['params'])).to be false
83
83
  end
84
84
 
85
85
  it "doesn't raise if the key provided" do
86
86
  @env['params']['mk'] = 'my value'
87
- @rp.key_valid?(@env['params']).should be true
87
+ expect(@rp.key_valid?(@env['params'])).to be true
88
88
  end
89
89
 
90
90
  it "doesn't raise if the array contains valid data" do
91
91
  @env['params']['mk'] = [1, 2, 3, 4]
92
- @rp.key_valid?(@env['params']).should be true
92
+ expect(@rp.key_valid?(@env['params'])).to be true
93
93
  end
94
94
 
95
95
  it "doesn't raise if the key provided is multiline and has blanks" do
96
96
  @env['params']['mk'] = "my\n \nvalue"
97
- @rp.key_valid?(@env['params']).should be true
97
+ expect(@rp.key_valid?(@env['params'])).to be true
98
98
  end
99
99
 
100
100
  it "doesn't raise if the key provided is an array and contains multiline with blanks" do
101
101
  @env['params']['mk'] = ["my\n \nvalue", "my\n \nother\n \nvalue"]
102
- @rp.key_valid?(@env['params']).should be true
102
+ expect(@rp.key_valid?(@env['params'])).to be true
103
103
  end
104
104
  end
105
105
  end
@@ -123,7 +123,7 @@ describe Goliath::Rack::Validation::RequiredParam do
123
123
  }
124
124
  }
125
125
 
126
- @rp.key_valid?(@env['params']).should be false
126
+ expect(@rp.key_valid?(@env['params'])).to be false
127
127
  end
128
128
 
129
129
  it "return true if key is present" do
@@ -134,7 +134,7 @@ describe Goliath::Rack::Validation::RequiredParam do
134
134
  }
135
135
  }
136
136
 
137
- @rp.key_valid?(@env['params']).should be true
137
+ expect(@rp.key_valid?(@env['params'])).to be true
138
138
  end
139
139
  end
140
140
 
@@ -157,7 +157,7 @@ describe Goliath::Rack::Validation::RequiredParam do
157
157
  }
158
158
  }
159
159
 
160
- @rp.key_valid?(@env['params']).should be false
160
+ expect(@rp.key_valid?(@env['params'])).to be false
161
161
  end
162
162
 
163
163
  it "return true if key is present" do
@@ -168,7 +168,7 @@ describe Goliath::Rack::Validation::RequiredParam do
168
168
  }
169
169
  }
170
170
 
171
- @rp.key_valid?(@env['params']).should be true
171
+ expect(@rp.key_valid?(@env['params'])).to be true
172
172
  end
173
173
  end
174
174
 
@@ -3,18 +3,18 @@ require 'goliath/rack/validation/required_value'
3
3
 
4
4
  describe Goliath::Rack::Validation::RequiredValue do
5
5
  it 'accepts an app' do
6
- lambda { Goliath::Rack::Validation::RequiredValue.new('my app') }.should_not raise_error
6
+ expect { Goliath::Rack::Validation::RequiredValue.new('my app') }.not_to raise_error
7
7
  end
8
8
 
9
9
  it 'accepts options on create' do
10
10
  opts = { :key => 2, :values => ["foo", "bar"] }
11
- lambda { Goliath::Rack::Validation::RequiredValue.new('my app', opts) }.should_not raise_error
11
+ expect { Goliath::Rack::Validation::RequiredValue.new('my app', opts) }.not_to raise_error
12
12
  end
13
13
 
14
14
 
15
15
  it 'turns a single option into an array' do
16
16
  rv = Goliath::Rack::Validation::RequiredValue.new('my app', :key => 2, :values => "foo")
17
- rv.values.should == ['foo']
17
+ expect(rv.values).to eq(['foo'])
18
18
  end
19
19
 
20
20
  describe 'with middleware' do
@@ -25,71 +25,71 @@ describe Goliath::Rack::Validation::RequiredValue do
25
25
  end
26
26
 
27
27
  it 'stores type and key options' do
28
- @rv.values.should == ['Monkey', 'frog']
29
- @rv.key.should == 'mk'
28
+ expect(@rv.values).to eq(['Monkey', 'frog'])
29
+ expect(@rv.key).to eq('mk')
30
30
  end
31
31
 
32
32
  it 'returns the app status, headers and body' do
33
33
  app_headers = {'Content-Type' => 'app'}
34
34
  app_body = {'b' => 'c'}
35
- @app.should_receive(:call).and_return([201, app_headers, app_body])
35
+ expect(@app).to receive(:call).and_return([201, app_headers, app_body])
36
36
 
37
37
  @env['params']['mk'] = 'Monkey'
38
38
 
39
39
  status, headers, body = @rv.call(@env)
40
- status.should == 201
41
- headers.should == app_headers
42
- body.should == app_body
40
+ expect(status).to eq(201)
41
+ expect(headers).to eq(app_headers)
42
+ expect(body).to eq(app_body)
43
43
  end
44
44
 
45
45
  context '#value_valid!' do
46
46
  it 'raises exception if the key is not provided' do
47
- @rv.value_valid?(@env['params']).should be false
47
+ expect(@rv.value_valid?(@env['params'])).to be false
48
48
  end
49
49
 
50
50
  it 'raises exception if the key is blank' do
51
51
  @env['params']['mk'] = ''
52
- @rv.value_valid?(@env['params']).should be false
52
+ expect(@rv.value_valid?(@env['params'])).to be false
53
53
  end
54
54
 
55
55
  it 'raises exception if the key is nil' do
56
56
  @env['params']['mk'] = nil
57
- @rv.value_valid?(@env['params']).should be false
57
+ expect(@rv.value_valid?(@env['params'])).to be false
58
58
  end
59
59
 
60
60
  it 'raises exception if the key is does not match' do
61
61
  @env['params']['mk'] = "blarg"
62
- @rv.value_valid?(@env['params']).should be false
62
+ expect(@rv.value_valid?(@env['params'])).to be false
63
63
  end
64
64
 
65
65
  it 'handles an empty array' do
66
66
  @env['params']['mk'] = []
67
- @rv.value_valid?(@env['params']).should be false
67
+ expect(@rv.value_valid?(@env['params'])).to be false
68
68
  end
69
69
 
70
70
  it 'handles an array of nils' do
71
71
  @env['params']['mk'] = [nil, nil, nil]
72
- @rv.value_valid?(@env['params']).should be false
72
+ expect(@rv.value_valid?(@env['params'])).to be false
73
73
  end
74
74
 
75
75
  it 'handles an array of blanks' do
76
76
  @env['params']['mk'] = ['', '', '']
77
- @rv.value_valid?(@env['params']).should be false
77
+ expect(@rv.value_valid?(@env['params'])).to be false
78
78
  end
79
79
 
80
80
  it "doesn't raise if the key is value" do
81
81
  @env['params']['mk'] = 'Monkey'
82
- @rv.value_valid?(@env['params']).should be true
82
+ expect(@rv.value_valid?(@env['params'])).to be true
83
83
  end
84
84
 
85
85
  it "doesn't raise if the array contains valid data" do
86
86
  @env['params']['mk'] = ['Monkey', 'frog']
87
- @rv.value_valid?(@env['params']).should be true
87
+ expect(@rv.value_valid?(@env['params'])).to be true
88
88
  end
89
89
 
90
90
  it 'raises if any of the array elements do not match' do
91
91
  @env['params']['mk'] = ["Monkey", "frog", "bat"]
92
- @rv.value_valid?(@env['params']).should be false
92
+ expect(@rv.value_valid?(@env['params'])).to be false
93
93
  end
94
94
  end
95
95
  end
@@ -14,15 +14,15 @@ describe Goliath::Request do
14
14
  env['INIT'] = 'init'
15
15
 
16
16
  r = Goliath::Request.new(nil, nil, env)
17
- r.env['INIT'].should == 'init'
17
+ expect(r.env['INIT']).to eq('init')
18
18
  end
19
19
 
20
20
  it 'initializes an async callback' do
21
- @r.env['async.callback'].should_not be_nil
21
+ expect(@r.env['async.callback']).not_to be_nil
22
22
  end
23
23
 
24
24
  it 'initializes request' do
25
- @r.instance_variable_get("@state").should == :processing
25
+ expect(@r.instance_variable_get("@state")).to eq(:processing)
26
26
  end
27
27
  end
28
28
 
@@ -32,8 +32,8 @@ describe Goliath::Request do
32
32
  env_mock = double('app').as_null_object
33
33
  request = Goliath::Request.new(app_mock, nil, env_mock)
34
34
 
35
- app_mock.should_receive(:call).with(request.env)
36
- request.should_receive(:post_process)
35
+ expect(app_mock).to receive(:call).with(request.env)
36
+ expect(request).to receive(:post_process)
37
37
 
38
38
  request.process
39
39
  end
@@ -41,50 +41,50 @@ describe Goliath::Request do
41
41
 
42
42
  describe 'finished?' do
43
43
  it "returns false if the request parsing has not yet finished" do
44
- @r.finished?.should be false
44
+ expect(@r.finished?).to be false
45
45
  end
46
46
 
47
47
  it 'returns true if we have finished request parsing' do
48
- @r.should_receive(:post_process).and_return(nil)
48
+ expect(@r).to receive(:post_process).and_return(nil)
49
49
  @r.process
50
50
 
51
- @r.finished?.should be true
51
+ expect(@r.finished?).to be true
52
52
  end
53
53
  end
54
54
 
55
55
  describe 'parse_headers' do
56
56
  it 'sets content_type correctly' do
57
57
  parser = double('parser').as_null_object
58
- parser.stub(:request_url).and_return('')
58
+ allow(parser).to receive(:request_url).and_return('')
59
59
 
60
60
  @r.parse_header({'Content-Type' => 'text/plain'}, parser)
61
- @r.env['CONTENT_TYPE'].should == 'text/plain'
61
+ expect(@r.env['CONTENT_TYPE']).to eq('text/plain')
62
62
  end
63
63
 
64
64
  it 'handles bad request urls' do
65
65
  parser = double('parser').as_null_object
66
- parser.stub(:request_url).and_return('/bad?params##')
66
+ allow(parser).to receive(:request_url).and_return('/bad?params##')
67
67
 
68
- @r.stub(:server_exception)
69
- @r.should_receive(:server_exception)
68
+ allow(@r).to receive(:server_exception)
69
+ expect(@r).to receive(:server_exception)
70
70
  @r.parse_header({}, parser)
71
71
  end
72
72
 
73
73
  it 'sets content_length correctly' do
74
74
  parser = double('parser').as_null_object
75
- parser.stub(:request_url).and_return('')
75
+ allow(parser).to receive(:request_url).and_return('')
76
76
 
77
77
  @r.parse_header({'Content-Length' => 42}, parser)
78
- @r.env['CONTENT_LENGTH'].should == 42
78
+ expect(@r.env['CONTENT_LENGTH']).to eq(42)
79
79
  end
80
80
 
81
81
  it 'sets server_name and server_port correctly' do
82
82
  parser = double('parser').as_null_object
83
- parser.stub(:request_url).and_return('')
83
+ allow(parser).to receive(:request_url).and_return('')
84
84
 
85
85
  @r.parse_header({'Host' => 'myhost.com:3000'}, parser)
86
- @r.env['SERVER_NAME'].should == 'myhost.com'
87
- @r.env['SERVER_PORT'].should == '3000'
86
+ expect(@r.env['SERVER_NAME']).to eq('myhost.com')
87
+ expect(@r.env['SERVER_PORT']).to eq('3000')
88
88
  end
89
89
  end
90
90
  end
@@ -8,28 +8,28 @@ describe Goliath::Response do
8
8
 
9
9
  it 'allows setting status' do
10
10
  @r.status = 400
11
- @r.status.should == 400
11
+ expect(@r.status).to eq(400)
12
12
  end
13
13
 
14
14
  it 'allows setting headers' do
15
15
  @r.headers = [['my_key', 'my_headers']]
16
- @r.headers.to_s.should == "my_key: my_headers\r\n"
16
+ expect(@r.headers.to_s).to eq("my_key: my_headers\r\n")
17
17
  end
18
18
 
19
19
  it 'allows setting body' do
20
20
  @r.body = 'my body'
21
- @r.body.should == 'my body'
21
+ expect(@r.body).to eq('my body')
22
22
  end
23
23
 
24
24
  it 'sets a default status' do
25
- @r.status.should == 200
25
+ expect(@r.status).to eq(200)
26
26
  end
27
27
 
28
28
  it 'sets default headers' do
29
- @r.headers.should_not be_nil
29
+ expect(@r.headers).not_to be_nil
30
30
  end
31
31
 
32
32
  it 'outputs the http header' do
33
- @r.head.should == "HTTP/1.1 200 OK\r\n"
33
+ expect(@r.head).to eq("HTTP/1.1 200 OK\r\n")
34
34
  end
35
35
  end
@@ -4,23 +4,23 @@ require 'goliath/runner'
4
4
  describe Goliath::Runner do
5
5
  before(:each) do
6
6
  @r = Goliath::Runner.new([], nil)
7
- @r.stub(:store_pid)
7
+ allow(@r).to receive(:store_pid)
8
8
 
9
9
  @log_mock = double('logger').as_null_object
10
- @r.stub(:setup_logger).and_return(@log_mock)
10
+ allow(@r).to receive(:setup_logger).and_return(@log_mock)
11
11
  end
12
12
 
13
13
  describe 'server execution' do
14
14
  describe 'daemonization' do
15
15
  it 'daemonizes if specified' do
16
- Process.should_receive(:fork)
16
+ expect(Process).to receive(:fork)
17
17
  @r.daemonize = true
18
18
  @r.run
19
19
  end
20
20
 
21
21
  it "doesn't daemonize if not specified" do
22
- Process.should_not_receive(:fork)
23
- @r.should_receive(:run_server)
22
+ expect(Process).not_to receive(:fork)
23
+ expect(@r).to receive(:run_server)
24
24
  @r.run
25
25
  end
26
26
  end
@@ -38,46 +38,46 @@ describe Goliath::Runner do
38
38
 
39
39
  describe 'without setting up file logger' do
40
40
  before(:each) do
41
- @r.stub(:setup_file_logger)
41
+ allow(@r).to receive(:setup_file_logger)
42
42
  end
43
43
 
44
44
  it 'configures the logger' do
45
45
  log = @r.send(:setup_logger)
46
- log.should_not be_nil
46
+ expect(log).not_to be_nil
47
47
  end
48
48
 
49
49
  [:debug, :warn, :info].each do |type|
50
50
  it "responds to #{type} messages" do
51
51
  log = @r.send(:setup_logger)
52
- log.respond_to?(type).should be true
52
+ expect(log.respond_to?(type)).to be true
53
53
  end
54
54
  end
55
55
 
56
56
  describe 'log level' do
57
57
  before(:each) do
58
- FileUtils.stub(:mkdir_p)
58
+ allow(FileUtils).to receive(:mkdir_p)
59
59
  end
60
60
 
61
61
  it 'sets the default log level' do
62
62
  log = @r.send(:setup_logger)
63
- log.level.should == Log4r::INFO
63
+ expect(log.level).to eq(Log4r::INFO)
64
64
  end
65
65
 
66
66
  it 'sets debug when verbose' do
67
67
  @r.verbose = true
68
68
  log = @r.send(:setup_logger)
69
- log.level.should == Log4r::DEBUG
69
+ expect(log.level).to eq(Log4r::DEBUG)
70
70
  end
71
71
  end
72
72
 
73
73
  describe 'file logger' do
74
74
  it "doesn't configure by default" do
75
- @r.should_not_receive(:setup_file_logger)
75
+ expect(@r).not_to receive(:setup_file_logger)
76
76
  log = @r.send(:setup_logger)
77
77
  end
78
78
 
79
79
  it 'configures if -l is provided' do
80
- @r.should_receive(:setup_file_logger)
80
+ expect(@r).to receive(:setup_file_logger)
81
81
  @r.log_file = 'out.log'
82
82
  log = @r.send(:setup_logger)
83
83
  end
@@ -85,12 +85,12 @@ describe Goliath::Runner do
85
85
 
86
86
  describe 'stdout logger' do
87
87
  it "doesn't configure by default" do
88
- @r.should_not_receive(:setup_stdout_logger)
88
+ expect(@r).not_to receive(:setup_stdout_logger)
89
89
  log = @r.send(:setup_logger)
90
90
  end
91
91
 
92
92
  it 'configures if -s is provided' do
93
- @r.should_receive(:setup_stdout_logger)
93
+ expect(@r).to receive(:setup_stdout_logger)
94
94
  @r.log_stdout = true
95
95
  log = @r.send(:setup_logger)
96
96
  end
@@ -100,7 +100,7 @@ describe Goliath::Runner do
100
100
 
101
101
  it "doesn't configure Log4r" do
102
102
  CustomLogger = Struct.new(:info, :debug, :error, :fatal)
103
- Log4r::Logger.should_not_receive(:new)
103
+ expect(Log4r::Logger).not_to receive(:new)
104
104
  @r.logger = CustomLogger.new
105
105
  log = @r.send(:setup_logger)
106
106
  end
@@ -109,10 +109,10 @@ describe Goliath::Runner do
109
109
  end
110
110
 
111
111
  it 'creates the log dir if neeed' do
112
- Log4r::FileOutputter.stub(:new)
112
+ allow(Log4r::FileOutputter).to receive(:new)
113
113
  log_mock = double('log').as_null_object
114
114
 
115
- FileUtils.should_receive(:mkdir_p).with('/my/log/dir')
115
+ expect(FileUtils).to receive(:mkdir_p).with('/my/log/dir')
116
116
 
117
117
  @r.log_file = '/my/log/dir/log.txt'
118
118
  @r.send(:setup_file_logger, log_mock, nil)
@@ -121,34 +121,34 @@ describe Goliath::Runner do
121
121
 
122
122
  it 'sets up the api if that implements the #setup method' do
123
123
  server_mock = double("Server").as_null_object
124
- server_mock.api.should_receive(:setup)
124
+ expect(server_mock.api).to receive(:setup)
125
125
 
126
- Goliath::Server.stub(:new).and_return(server_mock)
126
+ allow(Goliath::Server).to receive(:new).and_return(server_mock)
127
127
 
128
- @r.stub(:load_config).and_return({})
128
+ allow(@r).to receive(:load_config).and_return({})
129
129
  @r.send(:run_server)
130
130
  end
131
131
 
132
132
  it 'runs the server' do
133
133
  server_mock = double("Server").as_null_object
134
- server_mock.should_receive(:start)
134
+ expect(server_mock).to receive(:start)
135
135
 
136
- Goliath::Server.should_receive(:new).and_return(server_mock)
136
+ expect(Goliath::Server).to receive(:new).and_return(server_mock)
137
137
 
138
- @r.stub(:load_config).and_return({})
138
+ allow(@r).to receive(:load_config).and_return({})
139
139
  @r.send(:run_server)
140
140
  end
141
141
 
142
142
  it 'configures the server' do
143
143
  server_mock = Goliath::Server.new
144
- server_mock.stub(:start)
144
+ allow(server_mock).to receive(:start)
145
145
 
146
146
  @r.app = 'my_app'
147
147
 
148
- Goliath::Server.should_receive(:new).and_return(server_mock)
148
+ expect(Goliath::Server).to receive(:new).and_return(server_mock)
149
149
 
150
- server_mock.should_receive(:logger=).with(@log_mock)
151
- server_mock.should_receive(:app=).with('my_app')
150
+ expect(server_mock).to receive(:logger=).with(@log_mock)
151
+ expect(server_mock).to receive(:app=).with('my_app')
152
152
 
153
153
  @r.send(:run_server)
154
154
  end
@@ -161,17 +161,17 @@ describe Goliath::EnvironmentParser do
161
161
  end
162
162
 
163
163
  it 'returns the default environment if no other options are set' do
164
- Goliath::EnvironmentParser.parse.should == Goliath::DEFAULT_ENV
164
+ expect(Goliath::EnvironmentParser.parse).to eq(Goliath::DEFAULT_ENV)
165
165
  end
166
166
 
167
167
  it 'gives precendence to RACK_ENV over the default' do
168
168
  ENV['RACK_ENV'] = 'rack_env'
169
- Goliath::EnvironmentParser.parse.should == :rack_env
169
+ expect(Goliath::EnvironmentParser.parse).to eq(:rack_env)
170
170
  end
171
171
 
172
172
  it 'gives precendence to command-line flag over RACK_ENV' do
173
173
  ENV['RACK_ENV'] = 'rack_env'
174
174
  args = %w{ -e flag_env }
175
- Goliath::EnvironmentParser.parse(args).should == :flag_env
175
+ expect(Goliath::EnvironmentParser.parse(args)).to eq(:flag_env)
176
176
  end
177
177
  end