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

14 commits

Author SHA1 Message Date
Robin Wallin
0a50b5608d
Fix use with keyword arguments for Ruby 3.0 (#1701)
The added test case would, prior to the fix, fail, under Ruby 3.0, with the following error:

```
MiddlewareTest#test_handles_keyword_arguments_0:
ArgumentError: wrong number of arguments (given 2, expected 1)
```

The change itself was inspired by https://github.com/rack/rack/pull/1505
2021-06-02 12:20:44 -04:00
Kunpei Sakai
a5429833e4
avoid multiple errors even if params contains special values
The original fixes are #1506 and #1517.
This commit considers `FrozenError` and `TypeEror` for the case.
2019-04-22 22:39:32 +09:00
Kunpei Sakai
c686a10be6
avoid FrozenError when params contains frozen value
The error can be fixed by using dupped values.
The original code for testing is implemented by @programmarchy in #1479

Fixes #1478
Closes #1479
2018-12-16 04:46:53 +09:00
Vipul A M
23c2e197c8 - Removed test-unit dependency
- updated minitest to 5.0
- Removed Test::Unit::TestCase and started using Minitest::Test instead
- Fixed usage of assert_raise
- Fixed usage of refute_nil
- Fixed and removed usage of assert_nothing_raised
2015-01-11 01:00:47 +05:30
Zachary Scott
46e8bd67b3 First pass at block styles for tests
TODO:
* test/routing_test.rb
* test/settings_test.rb
2012-05-21 17:21:59 -04: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
Simon Rozet
af1ee6ae94 Get rid of Default
TODO: clean the options^Wsettings test
2009-10-18 01:18:53 +02: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
d7eabb9739 Fix middleware not running when app run as middleware [#161]
The app's middleware pipeline was ignored when the app itself was
run as middleware. This was due to the separate call paths for
middleware vs. endpoint apps. This change makes it so that both
endpoint and middleware apps are invoked via the same instance
level #call method.

One potentially confusing aspect of this change is that Base.new now
returns the head of the app's middleware pipeline. If no middleware
is used by the app, this will be an instance of the Base class;
however, if middleware is used, Base.new will return the head of
the middleware chain leading to the Base instance.
2009-02-26 22:02:39 -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
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
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
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