forked from postrank-labs/goliath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheartbeat_spec.rb
More file actions
47 lines (41 loc) · 1.32 KB
/
Copy pathheartbeat_spec.rb
File metadata and controls
47 lines (41 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'spec_helper'
require 'goliath/rack/heartbeat'
require 'goliath/env'
describe Goliath::Rack::Heartbeat do
it 'accepts an app' do
lambda { Goliath::Rack::Heartbeat.new('my app') }.should_not raise_error
end
describe 'with the middleware' do
before(:each) do
@app = mock('app').as_null_object
@env = Goliath::Env.new
@env['status'] = mock('status').as_null_object
@hb = Goliath::Rack::Heartbeat.new(@app)
end
it 'allows /status as a path prefix' do
@app.should_receive(:call)
@env['PATH_INFO'] = '/status_endpoint'
@hb.call(@env)
end
it "doesn't call the app when request /status" do
@app.should_not_receive(:call)
@env['PATH_INFO'] = '/status'
@hb.call(@env)
end
it 'returns the status, headers and body from the app on non-/status' do
@env['PATH_INFO'] = '/v1'
@app.should_receive(:call).and_return([200, {'a' => 'b'}, {'c' => 'd'}])
status, headers, body = @hb.call(@env)
status.should == 200
headers.should == {'a' => 'b'}
body.should == {'c' => 'd'}
end
it 'returns the correct status, headers and body on /status' do
@env['PATH_INFO'] = '/status'
status, headers, body = @hb.call(@env)
status.should == 200
headers.should == {}
body.should == 'OK'
end
end
end