Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
If no template is found, raise a 500 with message
Browse files Browse the repository at this point in the history
Closes #147
  • Loading branch information
Zachary Scott committed Jul 21, 2016
1 parent 4be26d7 commit fe860ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/sinatra/respond_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions spec/respond_with_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit fe860ec

Please sign in to comment.