Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'test_helper' | ||
require 'lotus/router' | ||
|
||
ErrorsRoutes = Lotus::Router.new do | ||
get '/without_message', to: 'errors#without_message' | ||
get '/with_message', to: 'errors#with_message' | ||
end | ||
|
||
AuthException = Class.new(StandardError) | ||
|
||
class ErrorsController | ||
include Lotus::Controller | ||
|
||
action 'WithoutMessage' do | ||
def call(params) | ||
raise AuthException | ||
end | ||
end | ||
|
||
action 'WithMessage' do | ||
def call(params) | ||
raise AuthException, %q{AuthException: you're not authorized to see this page!} | ||
end | ||
end | ||
end | ||
|
||
describe 'Reference exception in rack.errors' do | ||
before do | ||
@app = Rack::MockRequest.new(ErrorsRoutes) | ||
end | ||
|
||
it 'adds exception to rack.errors' do | ||
response = @app.get('/without_message') | ||
response.errors.must_equal "AuthException\n" | ||
end | ||
|
||
it 'adds exception message to rack.errors' do | ||
response = @app.get('/with_message') | ||
response.errors.must_equal "AuthException: you're not authorized to see this page!\n" | ||
end | ||
end |