Skip to content

Commit 22aff87

Browse files
committed
Added spec.
1 parent e3f5257 commit 22aff87

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/grape/middleware/exception_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ def call(env)
88
end
99
end
1010
end
11+
12+
class AccessDeniedApp
13+
class << self
14+
def error!(message, status=403)
15+
throw :error, :message => message, :status => status
16+
end
17+
def call(env)
18+
error!("Access Denied", 401)
19+
end
20+
end
21+
end
1122

1223
def app
1324
@app
@@ -70,4 +81,13 @@ def app
7081
last_response.body.should == '{:custom_formatter=>"rain!"}'
7182
end
7283

84+
it 'should not trap regular error! codes' do
85+
@app ||= Rack::Builder.app do
86+
use Grape::Middleware::Error
87+
run AccessDeniedApp
88+
end
89+
get '/'
90+
last_response.status.should == 401
91+
end
92+
7393
end

0 commit comments

Comments
 (0)