forked from postrank-labs/goliath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreloader_spec.rb
More file actions
43 lines (33 loc) · 857 Bytes
/
Copy pathreloader_spec.rb
File metadata and controls
43 lines (33 loc) · 857 Bytes
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
require 'spec_helper'
Goliath.env = :development
class ReloaderDev < Goliath::API
use Goliath::Rack::Params
end
class ReloaderAlreadyLoaded < Goliath::API
use ::Rack::Reloader, 0
use Goliath::Rack::Params
end
class ReloaderProd < Goliath::API
end
describe "Reloader" do
let(:err) { Proc.new { fail "API request failed" } }
before(:each) { Goliath.env = :development }
after(:each) { Goliath.env = :test }
def count(klass)
cnt = 0
klass.middlewares.each do |mw|
cnt += 1 if mw.first == ::Rack::Reloader
end
cnt
end
it 'adds reloader in dev mode' do
count(ReloaderDev).should == 1
end
it "doesn't add if it's already there in dev mode" do
count(ReloaderAlreadyLoaded).should == 1
end
it "doesn't add in prod mode" do
Goliath.env = :production
count(ReloaderProd).should == 0
end
end