goliath 1.0.4 → 1.0.6

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/goliath.gemspec +11 -7
  4. data/lib/goliath/api.rb +1 -1
  5. data/lib/goliath/connection.rb +15 -11
  6. data/lib/goliath/constants.rb +1 -0
  7. data/lib/goliath/rack/default_response_format.rb +3 -9
  8. data/lib/goliath/rack/formatters/json.rb +1 -1
  9. data/lib/goliath/rack/jsonp.rb +7 -2
  10. data/lib/goliath/rack/params.rb +4 -3
  11. data/lib/goliath/rack/validator.rb +1 -1
  12. data/lib/goliath/request.rb +37 -20
  13. data/lib/goliath/response.rb +2 -0
  14. data/lib/goliath/runner.rb +4 -3
  15. data/lib/goliath/server.rb +17 -2
  16. data/lib/goliath/test_helper_sse.rb +76 -0
  17. data/lib/goliath/validation/error.rb +4 -1
  18. data/lib/goliath/version.rb +1 -1
  19. data/spec/integration/async_request_processing.rb +2 -2
  20. data/spec/integration/chunked_streaming_spec.rb +1 -1
  21. data/spec/integration/early_abort_spec.rb +6 -6
  22. data/spec/integration/echo_spec.rb +7 -7
  23. data/spec/integration/empty_body_spec.rb +2 -2
  24. data/spec/integration/event_stream_spec.rb +50 -0
  25. data/spec/integration/exception_handling_spec.rb +202 -0
  26. data/spec/integration/http_log_spec.rb +16 -16
  27. data/spec/integration/jsonp_spec.rb +61 -10
  28. data/spec/integration/keepalive_spec.rb +2 -2
  29. data/spec/integration/pipelining_spec.rb +3 -3
  30. data/spec/integration/reloader_spec.rb +3 -3
  31. data/spec/integration/template_spec.rb +7 -7
  32. data/spec/integration/test_helper_spec.rb +3 -3
  33. data/spec/integration/trace_spec.rb +2 -2
  34. data/spec/integration/valid_spec.rb +25 -5
  35. data/spec/integration/websocket_spec.rb +2 -2
  36. data/spec/spec_helper.rb +1 -3
  37. data/spec/unit/api_spec.rb +1 -1
  38. data/spec/unit/connection_spec.rb +8 -8
  39. data/spec/unit/console_spec.rb +3 -3
  40. data/spec/unit/env_spec.rb +9 -9
  41. data/spec/unit/headers_spec.rb +8 -8
  42. data/spec/unit/rack/default_mime_type_spec.rb +3 -3
  43. data/spec/unit/rack/formatters/json_spec.rb +35 -13
  44. data/spec/unit/rack/formatters/plist_spec.rb +8 -8
  45. data/spec/unit/rack/formatters/xml_spec.rb +18 -18
  46. data/spec/unit/rack/formatters/yaml_spec.rb +13 -13
  47. data/spec/unit/rack/heartbeat_spec.rb +15 -15
  48. data/spec/unit/rack/params_spec.rb +99 -62
  49. data/spec/unit/rack/render_spec.rb +14 -14
  50. data/spec/unit/rack/validation/boolean_value_spec.rb +6 -6
  51. data/spec/unit/rack/validation/default_params_spec.rb +13 -13
  52. data/spec/unit/rack/validation/numeric_range_spec.rb +17 -17
  53. data/spec/unit/rack/validation/param_spec.rb +75 -75
  54. data/spec/unit/rack/validation/request_method_spec.rb +9 -9
  55. data/spec/unit/rack/validation/required_param_spec.rb +39 -39
  56. data/spec/unit/rack/validation/required_value_spec.rb +19 -19
  57. data/spec/unit/request_spec.rb +18 -18
  58. data/spec/unit/response_spec.rb +6 -6
  59. data/spec/unit/runner_spec.rb +31 -31
  60. data/spec/unit/server_spec.rb +21 -21
  61. data/spec/unit/validation/standard_http_errors_spec.rb +6 -6
  62. metadata +149 -94
  63. data/examples/around.rb +0 -38
  64. data/examples/clone.rb +0 -26
  65. data/examples/router.rb +0 -15
  66. data/examples/test.rb +0 -31
  67. data/examples/upload.rb +0 -17
@@ -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?param}')
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
@@ -8,50 +8,50 @@ describe Goliath::Server do
8
8
 
9
9
  describe 'defaults' do
10
10
  it 'to any interface' do
11
- @s.address.should == '0.0.0.0'
11
+ expect(@s.address).to eq('0.0.0.0')
12
12
  end
13
13
 
14
14
  it 'to port 9000' do
15
- @s.port.should == 9000
15
+ expect(@s.port).to eq(9000)
16
16
  end
17
17
  end
18
18
 
19
19
  describe 'configuration' do
20
20
  it 'accepts an address and port' do
21
21
  @s = Goliath::Server.new('10.2.1.1', 2020)
22
- @s.address.should == '10.2.1.1'
23
- @s.port.should == 2020
22
+ expect(@s.address).to eq('10.2.1.1')
23
+ expect(@s.port).to eq(2020)
24
24
  end
25
25
 
26
26
  it 'accepts a logger' do
27
27
  logger = double('logger')
28
28
  @s.logger = logger
29
- @s.logger.should == logger
29
+ expect(@s.logger).to eq(logger)
30
30
  end
31
31
 
32
32
  it 'accepts an app' do
33
33
  app = double('app')
34
34
  @s.app = app
35
- @s.app.should == app
35
+ expect(@s.app).to eq(app)
36
36
  end
37
37
 
38
38
  it 'accepts config' do
39
39
  config = double('config')
40
40
  @s.config = config
41
- @s.config.should == config
41
+ expect(@s.config).to eq(config)
42
42
  end
43
43
  end
44
44
 
45
45
  describe 'startup' do
46
46
  before(:each) do
47
- EM.should_receive(:synchrony).and_yield
47
+ expect(EM).to receive(:synchrony).and_yield
48
48
  end
49
49
 
50
50
  it 'starts' do
51
51
  addr = '10.2.1.1'
52
52
  port = 10000
53
53
 
54
- EM.should_receive(:start_server).with(addr, port, anything)
54
+ expect(EM).to receive(:start_server).with(addr, port, anything)
55
55
 
56
56
  @s.address = addr
57
57
  @s.port = port
@@ -62,9 +62,9 @@ describe Goliath::Server do
62
62
  app = double('application')
63
63
 
64
64
  conn = double("connection").as_null_object
65
- conn.should_receive(:app=).with(app)
65
+ expect(conn).to receive(:app=).with(app)
66
66
 
67
- EM.should_receive(:start_server).and_yield(conn)
67
+ expect(EM).to receive(:start_server).and_yield(conn)
68
68
 
69
69
  @s.app = app
70
70
  @s.start
@@ -74,9 +74,9 @@ describe Goliath::Server do
74
74
  logger = double('logger')
75
75
 
76
76
  conn = double("connection").as_null_object
77
- conn.should_receive(:logger=).with(logger)
77
+ expect(conn).to receive(:logger=).with(logger)
78
78
 
79
- EM.should_receive(:start_server).and_yield(conn)
79
+ expect(EM).to receive(:start_server).and_yield(conn)
80
80
 
81
81
  @s.logger = logger
82
82
  @s.start
@@ -86,9 +86,9 @@ describe Goliath::Server do
86
86
  status = double('status')
87
87
 
88
88
  conn = double("connection").as_null_object
89
- conn.should_receive(:status=).with(status)
89
+ expect(conn).to receive(:status=).with(status)
90
90
 
91
- EM.should_receive(:start_server).and_yield(conn)
91
+ expect(EM).to receive(:start_server).and_yield(conn)
92
92
 
93
93
  @s.status = status
94
94
  @s.start
@@ -96,9 +96,9 @@ describe Goliath::Server do
96
96
 
97
97
  it 'loads the config for each connection' do
98
98
  conn = double("connection").as_null_object
99
- EM.should_receive(:start_server).and_yield(conn)
99
+ expect(EM).to receive(:start_server).and_yield(conn)
100
100
 
101
- @s.should_receive(:load_config)
101
+ expect(@s).to receive(:load_config)
102
102
  @s.start
103
103
  end
104
104
  end
@@ -113,28 +113,28 @@ describe Goliath::Server do
113
113
  Goliath.env = :development
114
114
  block_run = false
115
115
  @s.environment('development') { block_run = true }
116
- block_run.should be_true
116
+ expect(block_run).to be true
117
117
  end
118
118
 
119
119
  it 'does not execute the block if the environment does not match' do
120
120
  Goliath.env = :development
121
121
  block_run = false
122
122
  @s.environment('test') { block_run = true }
123
- block_run.should be_false
123
+ expect(block_run).to be false
124
124
  end
125
125
 
126
126
  it 'accepts an array of environments' do
127
127
  Goliath.env = :development
128
128
  block_run = false
129
129
  @s.environment(['development', 'test']) { block_run = true }
130
- block_run.should be_true
130
+ expect(block_run).to be true
131
131
  end
132
132
 
133
133
  it 'does not run the block if the environment is not in the array' do
134
134
  Goliath.env = :production
135
135
  block_run = false
136
136
  @s.environment(['development', 'test']) { block_run = true }
137
- block_run.should be_false
137
+ expect(block_run).to be false
138
138
  end
139
139
  end
140
140
  end
@@ -3,19 +3,19 @@ require 'goliath/validation/standard_http_errors'
3
3
 
4
4
  describe Goliath::Validation::Error do
5
5
  it 'defines exceptions for each standard error response' do
6
- lambda { Goliath::Validation::BadRequestError.new }.should_not raise_error
7
- Goliath::Validation::BadRequestError.should < Goliath::Validation::Error
6
+ expect { Goliath::Validation::BadRequestError.new }.not_to raise_error
7
+ expect(Goliath::Validation::BadRequestError).to be < Goliath::Validation::Error
8
8
  end
9
9
 
10
10
  it 'defines InternalServerError not InternalServerErrorError' do
11
- lambda { Goliath::Validation::InternalServerError.new }.should_not raise_error
12
- Goliath::Validation::InternalServerError.should < Goliath::Validation::Error
11
+ expect { Goliath::Validation::InternalServerError.new }.not_to raise_error
12
+ expect(Goliath::Validation::InternalServerError).to be < Goliath::Validation::Error
13
13
  end
14
14
 
15
15
  it 'sets a default status code and message' do
16
16
  nfe = Goliath::Validation::NotFoundError.new
17
- nfe.status_code.should == '404'
18
- nfe.message.should == 'Not Found'
17
+ expect(nfe.status_code).to eq('404')
18
+ expect(nfe.message).to eq('Not Found')
19
19
  end
20
20
  end
21
21