Permalink
Browse files

If no template is found, raise a 500 with message

Closes #147
  • Loading branch information...
zzak committed Jul 21, 2016
1 parent 4be26d7 commit fe860ecbbfdb38da39d01b2b3ffc081e20e4eb8f
Showing with 8 additions and 6 deletions.
  1. +1 −1 lib/sinatra/respond_with.rb
  2. +7 −5 spec/respond_with_spec.rb
@@ -115,7 +115,7 @@ def finish
@app.halt result
end
end
@app.halt 406
@app.halt 500, "Unknown template engine"
end
def method_missing(method, *args, &block)
View
@@ -95,7 +95,8 @@ def req(*types)
it 'does not set up default handlers' do
respond_to
expect(req).not_to be_ok
expect(status).to eq(406)
expect(status).to eq(500)
expect(body).to eq("Unknown template engine")
end
end
@@ -181,10 +182,11 @@ def req(*types)
expect(req(:pdf).body).to eq("hello")
end
it 'results in a 406 if format cannot be produced' do
it 'results in a 500 if format cannot be produced' do
respond_with({})
expect(req(:html)).not_to be_ok
expect(status).to eq(406)
expect(status).to eq(500)
expect(body).to eq("Unknown template engine")
end
end
@@ -204,8 +206,8 @@ def req(*types)
it 'does not use name.engine for engines producing other formats' do
respond_with :not_html
expect(req(:html)).not_to be_ok
expect(status).to eq(406)
expect(body).to be_empty
expect(status).to eq(500)
expect(body).to eq("Unknown template engine")
end
it 'falls back to #json if no template is found' do

0 comments on commit fe860ec

Please sign in to comment.