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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2657a958a80151a0eab64c006eb13a4905156cc3
4
- data.tar.gz: b140e7bdc85173bb06adeef69b504d7ab39d5197
2
+ SHA256:
3
+ metadata.gz: dfbb6334b545d1cb281c256ecc8d127158b28ec6d2f9fdb5f75480d34444dc9d
4
+ data.tar.gz: 5a755161caf7c6ef1877197066ac628cec01211e247f452e6bf5ff65eb6ca3a1
5
5
  SHA512:
6
- metadata.gz: bdf5b587bcc2edefd5242b4c447e45787bd9affff51010c47484b9644ba005bc194d68b939c7117f78d375e3ebc16e05abc1292ff3b34626d9329fd140551957
7
- data.tar.gz: 1cec64325f506e5838ec7893055c5e15cd52375c0e435b8cab69057d17424aa535f02537eab764a551064a161baeab27245d3a00a451ca0ca8215e720c3d0f1e
6
+ metadata.gz: a56de2b0212a2e749a822b796040ce36bc318adcb20d347c825e426acf9eb7958525b74447a9f4e9e5273fb0b58398a8f92aaf9bbf0c45c5886d97fea002e079
7
+ data.tar.gz: 56c4b36ebfceabff78951ef70f71807215cba80ee27e985969899005fc7a0e0397b3df52617079b2172ca74cf14416e90adfc652a8d12e81e8e1a6fabe2c90b4
@@ -17,7 +17,7 @@ class Rasterize < Goliath::API
17
17
  url = PostRank::URI.clean(params['url'])
18
18
  hash = PostRank::URI.hash(url, :clean => false)
19
19
 
20
- if !File.exists? filename(hash)
20
+ if !File.exist? filename(hash)
21
21
  fiber = Fiber.current
22
22
  EM.system('phantomjs rasterize.js ' + url.to_s + ' ' + filename(hash)) do |output, status|
23
23
  env.logger.info "Phantom exit status: #{status}"
data/goliath.gemspec CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  s.add_development_dependency 'amqp', '>=0.7.1'
39
39
  s.add_development_dependency 'em-websocket-client'
40
40
  s.add_development_dependency 'em-eventsource'
41
+ s.add_development_dependency 'rack', '< 2'
41
42
 
42
43
  s.add_development_dependency 'tilt', '>=1.2.2'
43
44
  s.add_development_dependency 'haml', '>=3.0.25'
@@ -23,12 +23,13 @@ module Goliath
23
23
  @parser = Http::Parser.new
24
24
  @parser.on_headers_complete = proc do |h|
25
25
  env = Goliath::Env.new
26
- env[SERVER_PORT] = port.to_s
27
- env[RACK_LOGGER] = logger
28
- env[OPTIONS] = options
29
- env[STATUS] = status
30
- env[CONFIG] = config
31
- env[REMOTE_ADDR] = remote_address
26
+ env[SERVER_PORT] = port.to_s
27
+ env[RACK_LOGGER] = logger
28
+ env[OPTIONS] = options
29
+ env[STATUS] = status
30
+ env[CONFIG] = config
31
+ env[REMOTE_ADDR] = remote_address
32
+ env[RACK_URL_SCHEME] = options[:ssl] ? "https" : "http"
32
33
 
33
34
  r = Goliath::Request.new(@app, self, env)
34
35
  r.parse_header(h, @parser) do
@@ -41,7 +42,8 @@ module Goliath
41
42
  end
42
43
 
43
44
  @parser.on_body = proc do |data|
44
- @requests.first.parse(data)
45
+ req = @requests.first
46
+ req.parse(data) unless req.env[:terminate_connection]
45
47
  end
46
48
 
47
49
  @parser.on_message_complete = proc do
@@ -71,7 +73,7 @@ module Goliath
71
73
  end
72
74
  end
73
75
 
74
- rescue HTTP::Parser::Error => e
76
+ rescue HTTP::Parser::Error
75
77
  terminate_request(false)
76
78
  end
77
79
  end
@@ -83,15 +85,17 @@ module Goliath
83
85
  end
84
86
 
85
87
  def terminate_request(keep_alive)
86
- if req = @pending.shift
87
- @current = req
88
- @current.succeed
89
- elsif @current
88
+ if @current
90
89
  @current.close
91
90
  @current = nil
92
91
  end
93
92
 
94
93
  close_connection_after_writing rescue nil if !keep_alive
94
+
95
+ if req = @pending.shift
96
+ @current = req
97
+ @current.succeed
98
+ end
95
99
  end
96
100
 
97
101
  def remote_address
@@ -23,6 +23,7 @@ module Goliath
23
23
  RACK_VERSION_NUM = [1, 0]
24
24
  RACK_LOGGER = 'rack.logger'
25
25
  RACK_EXCEPTION = 'rack.exception'
26
+ RACK_URL_SCHEME = 'rack.url_scheme'
26
27
 
27
28
  ASYNC_CALLBACK = 'async.callback'
28
29
  ASYNC_HEADERS = 'async.headers'
@@ -4,17 +4,11 @@ module Goliath
4
4
  include Goliath::Rack::AsyncMiddleware
5
5
 
6
6
  def post_process(env, status, headers, body)
7
- return [status, headers, body] if body.respond_to?(:to_ary)
8
-
9
- new_body = []
10
- if body.respond_to?(:each)
11
- body.each { |chunk| new_body << chunk }
7
+ if body.is_a?(String)
8
+ [status, headers, [body]]
12
9
  else
13
- new_body << body
10
+ [status, headers, body]
14
11
  end
15
- new_body.collect! { |item| item.to_s }
16
-
17
- [status, headers, new_body.flatten]
18
12
  end
19
13
  end
20
14
  end
@@ -19,7 +19,7 @@ module Goliath
19
19
  end
20
20
 
21
21
  def json_response?(headers)
22
- headers['Content-Type'] =~ %r{^application/(json|javascript)}
22
+ headers['Content-Type'] =~ %r{^application/((vnd\.api\+)?json|javascript)}
23
23
  end
24
24
  end
25
25
  end
@@ -4,7 +4,7 @@ require 'rack/utils'
4
4
  module Goliath
5
5
  module Rack
6
6
  URL_ENCODED = %r{^application/x-www-form-urlencoded}
7
- JSON_ENCODED = %r{^application/json}
7
+ JSON_ENCODED = %r{^application/((vnd\.api\+)?json|javascript)}
8
8
 
9
9
  # A middle ware to parse params. This will parse both the
10
10
  # query string parameters and the body and place them into
@@ -251,7 +251,7 @@ module Goliath
251
251
  # @return [String | nil] Template file or nil if it doesn't exist.
252
252
  def find_template(views, name, engine)
253
253
  filename = ::File.join(views, "#{name}.#{engine}")
254
- File.exists?(filename) ? filename : nil
254
+ File.exist?(filename) ? filename : nil
255
255
  end
256
256
 
257
257
  # Renders a template with the given engine. Don't call this directly --
@@ -197,22 +197,14 @@ module Goliath
197
197
  callback do
198
198
  begin
199
199
  @response.status, @response.headers, @response.body = status, headers, body
200
- @response.each { |chunk| @conn.send_data(chunk) }
201
-
202
- elapsed_time = (Time.now.to_f - @env[:start_time]) * 1000
203
- begin
204
- Goliath::Request.log_block.call(@env, @response, elapsed_time)
205
- rescue => err
206
- # prevent an infinite loop if the block raised an error
207
- @env[RACK_LOGGER].error("log block raised #{err}")
208
- end
209
200
 
210
- @conn.terminate_request(keep_alive)
201
+ stream_data(@response.each) do
202
+ terminate_request
203
+ end
211
204
  rescue Exception => e
212
205
  server_exception(e)
213
206
  end
214
207
  end
215
-
216
208
  rescue Exception => e
217
209
  server_exception(e)
218
210
  end
@@ -220,6 +212,31 @@ module Goliath
220
212
 
221
213
  private
222
214
 
215
+ # Writes each chunk of the response data in a new tick. This achieves
216
+ # streaming, because EventMachine flushes the sent data to the socket at
217
+ # the end of each tick.
218
+ def stream_data(chunks, &block)
219
+ @conn.send_data(chunks.next)
220
+ EM.next_tick { stream_data(chunks, &block) }
221
+ rescue StopIteration
222
+ block.call
223
+ rescue Exception => e
224
+ server_exception(e)
225
+ end
226
+
227
+ # Logs the response time and terminates the request.
228
+ def terminate_request
229
+ elapsed_time = (Time.now.to_f - @env[:start_time]) * 1000
230
+ begin
231
+ Goliath::Request.log_block.call(@env, @response, elapsed_time)
232
+ rescue => err
233
+ # prevent an infinite loop if the block raised an error
234
+ @env[RACK_LOGGER].error("log block raised #{err}")
235
+ end
236
+
237
+ @conn.terminate_request(keep_alive)
238
+ end
239
+
223
240
  # Handles logging server exceptions
224
241
  #
225
242
  # @param e [Exception] The exception to log
@@ -228,20 +245,20 @@ module Goliath
228
245
  if e.is_a?(Goliath::Validation::Error)
229
246
  status, headers, body = [e.status_code, e.headers, ('{"error":"%s"}' % e.message)]
230
247
  else
231
- @env[RACK_LOGGER].error("#{e.message}\n#{e.backtrace.join("\n")}")
232
- message = Goliath.env?(:production) ? 'An error happened' : e.message
248
+ logthis = "#{e.backtrace[0]}: #{e.message} (#{e.class})\n"
249
+ e.backtrace[1..-1].each do |bt|
250
+ logthis += " from #{bt}\n"
251
+ end
252
+ @env.logger.error(logthis)
253
+ @env[RACK_EXCEPTION] = e
233
254
 
255
+ message = Goliath.env?(:production) ? 'An error happened' : e.message
234
256
  status, headers, body = [500, {}, message]
235
257
  end
236
258
 
237
259
  headers['Content-Length'] = body.bytesize.to_s
238
260
  @env[:terminate_connection] = true
239
261
  post_process([status, headers, body])
240
-
241
- # Mark the request as complete to force a flush on the response.
242
- # Note: #on_body and #response hooks may still fire if the data
243
- # is already in the parser buffer.
244
- succeed
245
262
  end
246
263
 
247
264
  # Used to determine if the connection should be kept open
@@ -13,7 +13,7 @@ module Goliath
13
13
  attr_accessor :status
14
14
 
15
15
  # The headers to send
16
- attr_accessor :headers
16
+ attr_reader :headers
17
17
 
18
18
  # The body to send
19
19
  attr_accessor :body
@@ -79,6 +79,8 @@ module Goliath
79
79
  # @yield [String] The header line, headers and body content
80
80
  # @return [Nil]
81
81
  def each
82
+ return enum_for(__method__) unless block_given?
83
+
82
84
  yield head
83
85
  yield headers_output
84
86
 
@@ -132,7 +132,7 @@ module Goliath
132
132
  def load_config(file = nil)
133
133
  api_name = api.class.to_s.gsub('::', '_').gsub(/([^_A-Z])([A-Z])/,'\1_\2').downcase!
134
134
  file ||= "#{config_dir}/#{api_name}.rb"
135
- return unless File.exists?(file)
135
+ return unless File.exist?(file)
136
136
 
137
137
  proc = Proc.new {} # create proc to grab binding
138
138
  eval(IO.read(file), proc.binding, file)
@@ -1,4 +1,4 @@
1
1
  module Goliath
2
2
  # The current version of Goliath
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.7'
4
4
  end
@@ -13,8 +13,8 @@ describe 'Async Request processing' do
13
13
 
14
14
  post_request(request_data, err) do |c|
15
15
  resp = MultiJson.load(c.response)
16
- resp['body'].should match('some=data')
17
- resp['head'].should include('X-Upload')
16
+ expect(resp['body']).to match('some=data')
17
+ expect(resp['head']).to include('X-Upload')
18
18
  end
19
19
  end
20
20
  end
@@ -27,7 +27,7 @@ describe "ChunkedStreaming" do
27
27
  it "should stream content" do
28
28
  with_api(ChunkedStreaming, {:verbose => true, :log_stdout => true}) do |server|
29
29
  streaming_client_connect('/streaming') do |client|
30
- client.receive.should == "chunked"
30
+ expect(client.receive).to eq("chunked")
31
31
  end
32
32
  end
33
33
  end
@@ -11,7 +11,7 @@ describe EarlyAbort do
11
11
  it "should return OK" do
12
12
  with_api(EarlyAbort) do
13
13
  get_request({}, err) do |c|
14
- c.response.should == "OK"
14
+ expect(c.response).to eq("OK")
15
15
  end
16
16
  end
17
17
  end
@@ -24,8 +24,8 @@ describe EarlyAbort do
24
24
  }
25
25
 
26
26
  post_request(request_data, err) do |c|
27
- c.response.should == "{\"error\":\"Can't handle requests with X-Crash: true.\"}"
28
- File.exist?("/tmp/goliath-test-error.log").should be false
27
+ expect(c.response).to eq("{\"error\":\"Can't handle requests with X-Crash: true.\"}")
28
+ expect(File.exist?("/tmp/goliath-test-error.log")).to be false
29
29
  end
30
30
  end
31
31
  end
@@ -35,8 +35,8 @@ describe EarlyAbort do
35
35
  request_data = { :body => "a" * 20 }
36
36
 
37
37
  post_request(request_data, err) do |c|
38
- c.response.should =~ /Payload size can't exceed 10 bytes/
39
- File.exist?("/tmp/goliath-test-error.log").should be false
38
+ expect(c.response).to match(/Payload size can't exceed 10 bytes/)
39
+ expect(File.exist?("/tmp/goliath-test-error.log")).to be false
40
40
  end
41
41
  end
42
42
  end
@@ -10,7 +10,7 @@ describe Echo do
10
10
  with_api(Echo) do
11
11
  get_request({:query => {:echo => 'test'}}, err) do |c|
12
12
  b = MultiJson.load(c.response)
13
- b['response'].should == 'test'
13
+ expect(b['response']).to eq('test')
14
14
  end
15
15
  end
16
16
  end
@@ -19,8 +19,8 @@ describe Echo do
19
19
  with_api(Echo) do
20
20
  get_request({}, err) do |c|
21
21
  b = MultiJson.load(c.response)
22
- b['error'].should_not be_nil
23
- b['error'].should == 'echo identifier missing'
22
+ expect(b['error']).not_to be_nil
23
+ expect(b['error']).to eq('echo identifier missing')
24
24
  end
25
25
  end
26
26
  end
@@ -29,7 +29,7 @@ describe Echo do
29
29
  with_api(Echo) do
30
30
  post_request({:body => {'echo' => 'test'}}, err) do |c|
31
31
  b = MultiJson.load(c.response)
32
- b['response'].should == 'test'
32
+ expect(b['response']).to eq('test')
33
33
  end
34
34
  end
35
35
  end
@@ -42,7 +42,7 @@ describe Echo do
42
42
  post_request({:body => body.to_s,
43
43
  :head => head}, err) do |c|
44
44
  b = MultiJson.load(c.response)
45
- b['response'].should == 'test'
45
+ expect(b['response']).to eq('test')
46
46
  end
47
47
  end
48
48
  end
@@ -55,7 +55,7 @@ describe Echo do
55
55
  post_request({:body => body.to_s,
56
56
  :head => head}, err) do |c|
57
57
  b = MultiJson.load(c.response)
58
- b['response'].should == 'My Echo'
58
+ expect(b['response']).to eq('My Echo')
59
59
  end
60
60
  end
61
61
  end
@@ -64,7 +64,7 @@ describe Echo do
64
64
  with_api(Echo) do
65
65
  patch_request({:body => {'echo' => 'test'}}, err) do |c|
66
66
  b = MultiJson.load(c.response)
67
- b['response'].should == 'test'
67
+ expect(b['response']).to eq('test')
68
68
  end
69
69
  end
70
70
  end
@@ -12,8 +12,8 @@ describe 'Empty body API' do
12
12
  it 'serves a 201 with no body' do
13
13
  with_api(Empty) do
14
14
  get_request({}, err) do |c|
15
- c.response_header.status.should == 201
16
- c.response_header['CONTENT_LENGTH'].should == '0'
15
+ expect(c.response_header.status).to eq(201)
16
+ expect(c.response_header['CONTENT_LENGTH']).to eq('0')
17
17
  end
18
18
  end
19
19
  end
@@ -30,8 +30,8 @@ describe 'EventStream' do
30
30
  sse_client_connect('/stream') do |client|
31
31
  client.listen_to('custom_event')
32
32
  EventStreamEndpoint.events.push(name: 'custom_event', data: 'content')
33
- client.receive_on('custom_event').should == ['content']
34
- client.receive.should == []
33
+ expect(client.receive_on('custom_event')).to eq(['content'])
34
+ expect(client.receive).to eq([])
35
35
  end
36
36
  end
37
37
  end
@@ -42,7 +42,7 @@ describe 'EventStream' do
42
42
  with_api(EventStreamEndpoint, {:verbose => true, :log_stdout => true}) do |server|
43
43
  sse_client_connect('/stream') do |client|
44
44
  EventStreamEndpoint.events.push(data: 'content')
45
- client.receive.should == ['content']
45
+ expect(client.receive).to eq(['content'])
46
46
  end
47
47
  end
48
48
  end
@@ -83,8 +83,8 @@ describe ExceptionHandlingAPI do
83
83
  it 'returns a normal response' do
84
84
  with_api(ExceptionHandlingAPI) do
85
85
  get_request({ query: query }, err) do |c|
86
- c.response_header.status.should == 200
87
- c.response.should == 'No exceptions raised'
86
+ expect(c.response_header.status).to eq(200)
87
+ expect(c.response).to eq('No exceptions raised')
88
88
  end
89
89
  end
90
90
  end
@@ -96,8 +96,8 @@ describe ExceptionHandlingAPI do
96
96
  it 'handles the exception using ExceptionHandlingMiddleware' do
97
97
  with_api(ExceptionHandlingAPI) do
98
98
  get_request({ query: query }, err) do |c|
99
- c.response_header.status.should == 200
100
- c.response.should == 'Exception raised: zoinks'
99
+ expect(c.response_header.status).to eq(200)
100
+ expect(c.response).to eq('Exception raised: zoinks')
101
101
  end
102
102
  end
103
103
  end
@@ -109,8 +109,8 @@ describe ExceptionHandlingAPI do
109
109
  it 'handles the exception using ExceptionHandlingMiddleware' do
110
110
  with_api(ExceptionHandlingAPI) do
111
111
  get_request({ query: query }, err) do |c|
112
- c.response_header.status.should == 200
113
- c.response.should == 'Exception raised: jinkies'
112
+ expect(c.response_header.status).to eq(200)
113
+ expect(c.response).to eq('Exception raised: jinkies')
114
114
  end
115
115
  end
116
116
  end
@@ -122,8 +122,8 @@ describe ExceptionHandlingAPI do
122
122
  it 'returns a validation error generated by Goliath::Rack::Params' do
123
123
  with_api(ExceptionHandlingAPI) do
124
124
  get_request({ query: query }, err) do |c|
125
- c.response_header.status.should == 400
126
- c.response.should == "[:error, \"Invalid parameters: Rack::Utils::ParameterTypeError\"]"
125
+ expect(c.response_header.status).to eq(400)
126
+ expect(c.response).to eq("[:error, \"Invalid parameters: Rack::Utils::ParameterTypeError\"]")
127
127
  end
128
128
  end
129
129
  end
@@ -154,8 +154,8 @@ describe PassiveExceptionHandlingAPI do
154
154
  it 'returns a normal response' do
155
155
  with_api(PassiveExceptionHandlingAPI) do
156
156
  get_request({ query: query }, err) do |c|
157
- c.response_header.status.should == 200
158
- c.response.should == 'No exceptions raised'
157
+ expect(c.response_header.status).to eq(200)
158
+ expect(c.response).to eq('No exceptions raised')
159
159
  end
160
160
  end
161
161
  end
@@ -167,8 +167,8 @@ describe PassiveExceptionHandlingAPI do
167
167
  it 'returns the server error generated by Goliath::Request#process' do
168
168
  with_api(PassiveExceptionHandlingAPI) do
169
169
  get_request({ query: query }, err) do |c|
170
- c.response_header.status.should == 500
171
- c.response.should == 'ruh-roh'
170
+ expect(c.response_header.status).to eq(500)
171
+ expect(c.response).to eq('ruh-roh')
172
172
  end
173
173
  end
174
174
  end
@@ -180,8 +180,8 @@ describe PassiveExceptionHandlingAPI do
180
180
  it 'returns the validation error generated by Goliath::API#call' do
181
181
  with_api(PassiveExceptionHandlingAPI) do
182
182
  get_request({ query: query }, err) do |c|
183
- c.response_header.status.should == 500
184
- c.response.should == '[:error, "puppy-power"]'
183
+ expect(c.response_header.status).to eq(500)
184
+ expect(c.response).to eq('[:error, "puppy-power"]')
185
185
  end
186
186
  end
187
187
  end
@@ -193,8 +193,8 @@ describe PassiveExceptionHandlingAPI do
193
193
  it 'returns a validation error generated by Goliath::Rack::Params' do
194
194
  with_api(PassiveExceptionHandlingAPI) do
195
195
  get_request({ query: query }, err) do |c|
196
- c.response_header.status.should == 400
197
- c.response.should == '[:error, "Invalid parameters: Rack::Utils::ParameterTypeError"]'
196
+ expect(c.response_header.status).to eq(400)
197
+ expect(c.response).to eq('[:error, "Invalid parameters: Rack::Utils::ParameterTypeError"]')
198
198
  end
199
199
  end
200
200
  end
@@ -42,7 +42,7 @@ describe HttpLog do
42
42
  mock_mongo(api)
43
43
 
44
44
  get_request({}, err) do |c|
45
- c.response_header.status.should == 200
45
+ expect(c.response_header.status).to eq(200)
46
46
  end
47
47
  end
48
48
  end
@@ -53,9 +53,9 @@ describe HttpLog do
53
53
  mock_mongo(api)
54
54
 
55
55
  get_request({}, err) do |c|
56
- c.response_header.status.should == 200
57
- c.response_header['SPECIAL'].should == 'Header'
58
- c.response.should == 'Hello from Responder'
56
+ expect(c.response_header.status).to eq(200)
57
+ expect(c.response_header['SPECIAL']).to eq('Header')
58
+ expect(c.response).to eq('Hello from Responder')
59
59
  end
60
60
  end
61
61
  end
@@ -63,8 +63,8 @@ describe HttpLog do
63
63
  context 'HTTP header handling' do
64
64
  it 'transforms back properly' do
65
65
  hl = HttpLog.new
66
- hl.to_http_header("SPECIAL").should == 'Special'
67
- hl.to_http_header("CONTENT_TYPE").should == 'Content-Type'
66
+ expect(hl.to_http_header("SPECIAL")).to eq('Special')
67
+ expect(hl.to_http_header("CONTENT_TYPE")).to eq('Content-Type')
68
68
  end
69
69
  end
70
70
 
@@ -75,8 +75,8 @@ describe HttpLog do
75
75
  mock_mongo(api)
76
76
 
77
77
  get_request({:query => {:first => :foo, :second => :bar, :third => :baz}}, err) do |c|
78
- c.response_header.status.should == 200
79
- c.response_header["PARAMS"].should == "first: foo|second: bar|third: baz"
78
+ expect(c.response_header.status).to eq(200)
79
+ expect(c.response_header["PARAMS"]).to eq("first: foo|second: bar|third: baz")
80
80
  end
81
81
  end
82
82
  end
@@ -89,8 +89,8 @@ describe HttpLog do
89
89
  mock_mongo(api)
90
90
 
91
91
  get_request({:path => '/my/request/path'}, err) do |c|
92
- c.response_header.status.should == 200
93
- c.response_header['PATH'].should == '/my/request/path'
92
+ expect(c.response_header.status).to eq(200)
93
+ expect(c.response_header['PATH']).to eq('/my/request/path')
94
94
  end
95
95
  end
96
96
  end
@@ -103,8 +103,8 @@ describe HttpLog do
103
103
  mock_mongo(api)
104
104
 
105
105
  get_request({:head => {:first => :foo, :second => :bar}}, err) do |c|
106
- c.response_header.status.should == 200
107
- c.response_header["HEADERS"].should =~ /First: foo\|Second: bar/
106
+ expect(c.response_header.status).to eq(200)
107
+ expect(c.response_header["HEADERS"]).to match(/First: foo\|Second: bar/)
108
108
  end
109
109
  end
110
110
  end
@@ -117,8 +117,8 @@ describe HttpLog do
117
117
  mock_mongo(api)
118
118
 
119
119
  get_request({}, err) do |c|
120
- c.response_header.status.should == 200
121
- c.response_header["METHOD"].should == "GET"
120
+ expect(c.response_header.status).to eq(200)
121
+ expect(c.response_header["METHOD"]).to eq("GET")
122
122
  end
123
123
  end
124
124
  end
@@ -129,8 +129,8 @@ describe HttpLog do
129
129
  mock_mongo(api)
130
130
 
131
131
  post_request({}, err) do |c|
132
- c.response_header.status.should == 200
133
- c.response_header["METHOD"].should == "POST"
132
+ expect(c.response_header.status).to eq(200)
133
+ expect(c.response_header["METHOD"]).to eq("POST")
134
134
  end
135
135
  end
136
136
  end
@@ -30,7 +30,7 @@ describe 'JSONP' do
30
30
  it 'does not alter the content type' do
31
31
  with_api(JSON_API) do
32
32
  get_request({ query: query }, err) do |c|
33
- c.response_header['CONTENT_TYPE'].should =~ %r{^application/json}
33
+ expect(c.response_header['CONTENT_TYPE']).to match(%r{^application/json})
34
34
  end
35
35
  end
36
36
  end
@@ -38,7 +38,7 @@ describe 'JSONP' do
38
38
  it 'does not alter the content length' do
39
39
  with_api(JSON_API) do
40
40
  get_request({ query: query }, err) do |c|
41
- c.response_header['CONTENT_LENGTH'].to_i.should == 2
41
+ expect(c.response_header['CONTENT_LENGTH'].to_i).to eq(2)
42
42
  end
43
43
  end
44
44
  end
@@ -46,7 +46,7 @@ describe 'JSONP' do
46
46
  it 'does not wrap the response with anything' do
47
47
  with_api(JSON_API) do
48
48
  get_request({ query: query }, err) do |c|
49
- c.response.should == 'OK'
49
+ expect(c.response).to eq('OK')
50
50
  end
51
51
  end
52
52
  end
@@ -58,7 +58,7 @@ describe 'JSONP' do
58
58
  it 'adjusts the content type' do
59
59
  with_api(JSON_API) do
60
60
  get_request({ query: query }, err) do |c|
61
- c.response_header['CONTENT_TYPE'].should =~ %r{^application/javascript}
61
+ expect(c.response_header['CONTENT_TYPE']).to match(%r{^application/javascript})
62
62
  end
63
63
  end
64
64
  end
@@ -66,7 +66,7 @@ describe 'JSONP' do
66
66
  it 'adjusts the content length' do
67
67
  with_api(JSON_API) do
68
68
  get_request({ query: query }, err) do |c|
69
- c.response_header['CONTENT_LENGTH'].to_i.should == 8
69
+ expect(c.response_header['CONTENT_LENGTH'].to_i).to eq(8)
70
70
  end
71
71
  end
72
72
  end
@@ -74,7 +74,7 @@ describe 'JSONP' do
74
74
  it 'wraps response with callback' do
75
75
  with_api(JSON_API) do
76
76
  get_request({ query: query }, err) do |c|
77
- c.response.should =~ /^test\(.*\)$/
77
+ expect(c.response).to match(/^test\(.*\)$/)
78
78
  end
79
79
  end
80
80
  end