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

25 commits

Author SHA1 Message Date
Joshua Peek
f9a792396c Set X-Cascade header when using pass
Setting X-Cascade: pass allows middleware outside the Sinatra stack
to continue trying to match the request.

Signed-off-by: Ryan Tomayko <rtomayko@gmail.com>
2009-12-23 20:48:19 -08:00
Simon Rozet
5da3460f90 Allow to register a mime type with mime_type 2009-10-12 02:02:07 -07:00
Simon Rozet
31bf026087 Rename media_type to mime_type for symmetry with Rack::Mime.mime_type 2009-10-12 02:02:06 -07:00
Simon Rozet
341e3369d1 Stop disabling sessions in test environement
Manually `disable :sessions` if you want to manually pass in
the `rack.session` env key in your tests.
2009-10-04 15:52:10 +02:00
Ryan Tomayko
c6ea22bb8f Add cache_control and expires helper methods [#247] 2009-10-04 15:27:18 +02: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
Ryan Tomayko
ebceae7b1a fix missing const error in tests under ruby 1.9 2009-04-19 19:56:16 -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
4fc9cb8b65 Undeprecate headers helper method [#125] 2009-03-02 15:22:44 -08:00
Ryan Tomayko
6fd8aaadd1 Move a few specs out of base_test and into more appropriate tests 2009-02-22 01:04:01 -08:00
Julio Capote
fa6eb90bf3 added test for redirect back 2009-02-20 15:59:19 -08:00
Ryan Tomayko
33087977ef Fix helpers blocks failing when aliasing Base methods
The following would fail with a "undefined method `escape_html'"
exception because the block was being evaluated within a new module
and then included in Base. i.e., the following no longer worked:

    helpers { alias_method :h, :escape_html }

This was introduced just recently as part of the extensions work
foca did.
2009-02-07 11:26:32 -08: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
Nicolas Sanguinetti
c094757b08 Add #helpers into Sinatra::Base [#134 state:resolved]
Signed-off-by: Ryan Tomayko <rtomayko@gmail.com>
2009-01-26 11:21:53 -08:00
Ryan Tomayko
877bfb379c Fix send_file :disposition compat issues [#128] 2009-01-24 21:31:45 -08:00
Ryan Tomayko
a08d2e80b2 More detailed context names in helpers specs 2009-01-24 21:31:45 -08:00
Simon Rozet
045f93be91 Convert tests to custom test/spec/mini [#87]
The "spec" task has been removed and Rake's built in
test helper is used to run specs now so we should be able to
test with multiple installed versions of Ruby.
2009-01-20 12:23:15 -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
Ryan Tomayko
123cc5b5ac Depend on Rack 0.9.0 (up from 0.4.0)
* Remove the Rack::MethodOverride class from sinatra since it's
  included with rack core now.

* Update mime type handling to work with Rack 0.9.0's new
  Rack::Mime module.
2009-01-06 15:35:58 -08:00
Ryan Tomayko
1c124f5d44 unbreak send_file compat specs; add media_type helper 2008-12-22 03:12: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