kemalcr / spec-kemal

Easy testing for Kemal
http://kemalcr.com/
MIT License
55 stars 18 forks source link

Errors in tests render error page #17

Closed cromega closed 1 year ago

cromega commented 4 years ago

I'm having trouble TDD-ing a Kemal app. When a runtime error happens Kemal renders the exception helper page, which gives a pretty poor testing experience:

response.body.should eq "[]"

For example, when a JSON parsing error occurs:

       Expected: "[]"
            got: "<!DOCTYPE html>\n<html>\n<head>\n    \n    <meta charset=\"utf-8\">\n    <title>Error 500 at GET /tube - Missing JSON attribute: statuses</title>\n    <meta name=\"viewport\" content=\"width=device-width\">\n    <style>/*! normalize.css v4.2.0 | MIT License | github.

etc.

The functionality I'm looking for is the ability to tell Kemal to raise an error when it happens instead of rendering the error page. SInatra has a few nifty switches (eg: raise_errors), which are automatically enabled when RACK_ENV is "test".

I couldn't find anything related in the docs of Kemal and Kemal-spec.

cromega commented 4 years ago

By wading through the code I've found out about Kemal.config.always_rescue.

henrikac commented 3 years ago

@cromega would a solution to this be to just mention it in the README/documentation?

cromega commented 3 years ago

@henrikac Certainly, it is a very useful thing to mention, along with all other undocumented options.