1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
Commit graph

27 commits

Author SHA1 Message Date
Konstantin Haase
97e1bd2c80 let use_code default to false, remove warning. fixes #497 2012-05-13 21:06:54 +02:00
snaggled
4f0e1d4ef3 allowing a sequence of error blocks with the same http status code to be chained 2012-04-25 20:09:09 -05:00
Konstantin Haase
0d85006d01 deprecate Exception#code usage, ignore values that are not between 400 and 599. fixes #423. 2011-12-31 12:46:41 +01:00
Konstantin Haase
5b9d3dae7e pass exception object to error block, fixes #323 2011-07-24 13:45:42 +02:00
Konstantin Haase
9d29e6ff60 do not raise NotFound exceptions, even if show_exceptions is enabled, fixes #324 2011-07-24 13:20:28 +02:00
Konstantin Haase
d8fc41c822 honor Exception#code if present 2011-06-10 13:21:37 +02:00
Konstantin Haase
b391e7f1fe allow passing more than one argument to #error 2011-06-05 09:40:20 +02:00
Konstantin Haase
2e0030f115 if an error handler is registered for some exception class, let it also handle subclasses 2011-06-04 20:09:16 +02:00
Konstantin Haase
e001d62669 adjust require lines for test helper, so it also works properly on 1.9.2 2011-05-11 09:44:02 +02:00
Ryan Tomayko
4e71959595 error handlers always override raise_errors option 2010-03-04 05:40:18 -08:00
Ryan Tomayko
5c405a76d1 Better error mapping inheritance 2009-06-07 04:12:20 -07:00
Tim Carey-Smith
da37a88395 Less warnings to sate zenspider's needs 2009-05-18 03:36:03 -07:00
Simon Rozet
2fa9fd81bb Use Rack::Test instead of Sinatra::Test for tests 2009-05-18 02:51:44 -07:00
Simon Rozet
ff0d068687 Use contest instead of test/spec/mini
See <http://github.com/citrusbyte/contest> for more info. The
contest.rb file is included under the test/ directory.
2009-03-31 02:23:48 -07:00
Ryan Tomayko
d074e0c6f0 Fix constant resolution in specs under 1.9
The way constants are set/resolved in class_eval blocks seems
to have changed significantly. Move constants to top-level to
remedy the situation for now.
2009-02-02 18:49:11 -08:00
Ryan Tomayko
661090eb53 Allow assertions in mock_app request context
I changed the ".should." style to use "fail" when we
converted to test/unit style but I'd rather use asserts
here.
2009-01-15 04:18:18 -08:00
Ryan Tomayko
72a6e01daf use Test::Unit style assertions in Sinatra specs 2009-01-14 14:00:26 -08:00
Ryan Tomayko
c00a25ee41 Test framework refactoring
* Adds test/helper.rb and moves mock_app and other code specific
  to testing the framework out of Sinatra::Test.
* Do not require test/unit. The sinatra/test/unit,
  sinatra/test/spec, and sinatra/test/rspec files can be used to
  choose the framework.
* Add Sinatra::TestHarness, which should act similar to the
  Rack::Session proposal here: http://gist.github.com/41270
* Update the README with information on using the different test
  frameworks.
2009-01-14 07:52:04 -08:00
Markus Prinz
3502741e89 Test for not_found, which was added recently for backward compatibility 2009-01-13 12:54:22 -08:00
Ryan Tomayko
b5faa571f5 Dump backtrace to rack.errors on unhandled exception
Also added a dump_errors option so that this can be disabled
when necessary.
2009-01-09 02:28:09 -08:00
Ryan Tomayko
ed923caf42 improve test coverage 2008-12-21 02:52:46 -08:00
Ryan Tomayko
a734cf38ac I knew I shoulda taken that left turn at Hoboken
This is a fairly large reworking of Sinatra's innards. Although
most of the internal implementation has been modified, it
provides the same basic feature set and is meant to be compatible
with Sinatra 0.3.2.

* The Event and EventContext classes have been removed. Sinatra
  applications are now defined within the class context of a
  Sinatra::Base subclass; each request is processed within a new
  instance.

* Sinatra::Base can be used as a base class for multiple
  Rack applications within a single process and can be used as
  Rack middleware.

* The routing and result type processing implementation has been
  simplified and enhanced a bit. There's a new route conditions
  system for things like :agent/:host matching and a request
  level #pass method has been added to allow an event handler to
  exit immediately, passing control to the next matching route.

* Regular expressions may now be used in route patterns. Captures
  are available as an array from "params[:captures]".

* The #body helper method now takes a block. The block is not
  evaluated until an attempt is made to read the body.

* Options are now dynamically generated class attributes on the
  Sinatra::Base subclass (instead of OpenStruct); options are
  inherited by subclasses and may be overridden up the
  inheritance hierarchy. The Base.set manages all option related
  stuff.

* The application file (app_file) detection heuristics are bit
  more sane now. This fixes some bugs with reloading and
  public/views directory detection. All thin / passenger issues
  of these type should be better now.

* Error mappings are now split into to distinct layers: exception
  mappings and custom error pages. Exception mappings are registered
  with 'error(Exception)' and are run only when the app raises an
  exception. Custom error pages are registered with error(status_code)
  and are run any time the response has the status code specified.
  It's also possible to register an error page for a range of status
  codes: 'error(500..599)'.

* The spec and unit testing extensions have been modified to take
  advantage of the ability to have multiple Sinatra applications.
  The Sinatra::Test module must be included within the TestCase
  in order to take advantage of these methods (unless the
  'sinatra/compat' library has been required).

* Rebuilt specs from scratch for better coverage and
  organization. Sinatra 3.2 unit tests have been retained
  under ./compat to ensure a baseline level of compatibility with
  previous versions; use the 'rake compat' task to run these.

A large number of existing Sinatra idioms have been deprecated but
continue to be supported through the 'sinatra/compat' library.

* The "set_option" and "set_options" methods have been deprecated
  due to redundancy; use "set".

* The "env" option (Sinatra::Base.env) has been renamed to "environment"
  and deprecated because it's too easy to confuse with the request-level
  Rack environment Hash (Sinatra::Base#env).

* The request level "stop" method has been renamed "halt" and
  deprecated. This is for consistency with `throw :halt`.

* The request level "entity_tag" method has been renamed "etag" and
  deprecated. Both versions were previously supported.

* The request level "headers" method has been deprecated. Use
  response['Header-Name'] to access and modify response headers.

* Sinatra.application is deprecated. Use Sinatra::Application instead.

* Setting Sinatra.application = nil to reset an application is
  deprecated. You shouldn't have to reset objects anymore.

* The Sinatra.default_options Hash is deprecated. Modifying this object now
  results in "set(key, value)" invocations on the Sinatra::Base
  subclass.

* The "body.to_result" convention has been deprecated.

* The ServerError exception has been deprecated. Any Exception is now
  considered a ServerError.
2008-12-20 18:45:28 -08:00
Ryan Tomayko
3105f21132 make raise_errors option more reliable
The raise_errors option was implemented as part of
the default error handler making it worthless in development
mode or with a custom error handler. This moves the
implementation to the core dispatch method.

While here, clean up the Error class a bit, making it
use the options provided and pass the correct HTTP status
code.
2008-09-07 04:16:25 -07:00
Ryan Tomayko
60d50062d7 Fix whitespace errors across all source files and tests
I can't stand this shit anymore.
2008-08-31 02:10:37 -07:00
Blake Mizerany
0eca3f46c7 raise errors from error
This allows us to test custom errors easier
2008-04-01 14:20:26 -07:00
Blake Mizerany
1f07ba27b2 No more Error codes. Map them by Class name 2008-02-24 16:43:39 -08:00
Blake Mizerany
ba2d234cce i can has error map? 2008-02-23 17:00:04 -08:00