Commit Graph

28 Commits

Author SHA1 Message Date
Eloy Pérez f10e571f4d
Minor cleaning setting up tests (#1875)
We use minitest for Sinatra's test suite but we weren't using its rake task. I've updated the Rakefile to require and use Minitest default rake task to simplify.

Another change is to rename the `helper.rb` file to `test_helper.rb` because I think that name is used more in the community and require it directly without calling `File.expand_path`
2023-02-12 19:09:35 +01:00
Antonio Terceiro c5b8872473 Tests against Haml 6
In Haml 6, = escapes the results of the Ruby expression by default. If
you want that to be a nested  template it needs to be called with !=.

Also, attr_wrapper is no longer a valid option.
2022-12-24 11:03:06 -03:00
Eloy Pérez c112b9697f Update haml and slim dependencies in tests 2022-02-27 12:26:32 +01:00
Olle Jonsson 1559a20b06 refactor: use __dir__ in File.expand_path
__dir__ is nice, and available.
2022-02-02 15:58:11 -05:00
Olle Jonsson 330d9b4364
Ruby 2: use __dir__ instead of File.dirname(__FILE__) (#1341) 2020-03-13 17:20:04 -04:00
Horaciob 4c0ec16648 deleting unnecesary to_s 2017-06-25 11:19:22 +02: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
Vipul A M 4fa3d9acb0 Just some typos, here and there! 2013-03-14 23:50:51 +05:30
Alexey Muranov ea0d9673ed Tests: 5 template helpers can nest layouts 2013-02-25 19:08:28 +01:00
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
elij e16bc71590 Explicitly handle the exception for failed loading.
The exception handler was only catching RuntimeError, which probably
should not be caught by the harness (so a test fails), when it should
have been catching LoadError exceptions (module not present to test).

Signed-off-by: Konstantin Haase <konstantin.mailinglists@googlemail.com>
2011-01-31 10:34:41 +01:00
Konstantin Haase 7e80e3752e add test for locals passed to haml 2010-12-16 22:57:24 +01:00
Ryan Tomayko e1638a43ad skip haml / sass tests when they fail to load due to stupid bullshit
Both haml and sass have the retarded behavior of trying to read a
VERSION file outside their lib directory. Installing haml or sass
like a sane person (i.e. into a shared lib directory) and they fail
on require with ENOENT.

Ugh.
2010-03-15 19:23:58 -07:00
Blake Mizerany 801163e9f3 closes #9779 Auto-require haml/erb/builder/sass
this is causing thread-saftey issues.
2009-04-24 17:59:39 -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 49adaa5362 Sane template options [#191]
* The options hash now takes the :views, :layout, and :locals
  options but also any template-specific options. The generic
  options are removed before calling the template specific render
  method.

* The haml ":options" and ":haml" options are deprecated. These
  should be merged in directly with the options hash.

* The sass ":sass" option is deprecated. Merge directly with the
  options hash instead.

* All template engines have an app-level option named the same as
  their engine (erb, haml, sass, etc.). This must be a hash and is
  merged with the options passed to the render method.

* The :views_directory option is deprecated; renamed :views.
2009-03-31 01:58:47 -07:00
kematzy d359dc9c4d Merge app-level haml/sass options with call options [#184]
Ensures globally set Haml/Sass configurations can be overridden on
an individual call basis, while retaining the global values.

Renamed the #haml() :options key to :haml_options for
clarity and consistency with the #sass method.
2009-03-27 08:43:46 -07: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
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
Simon Rozet 23999054c6 Add the possibility to configure options that are passed to Haml::Engine when evalutating HAML template.
Options can be configured in two different ways:

* Application-wide, using set_option :haml
  e.g.: set_option :haml, :format      => :haml4,
                          :escape_html => true

* By passing options directly to the `haml` helper
  e.g.: haml '%strong Hello World', :options => {:format => :html4}

Note that if you use both way, options will be merged.
2008-04-19 16:43:12 +02:00
Blake Mizerany 6bda16b9c1 added `template` to DSL 2008-03-26 23:53:31 -07:00
Blake Mizerany 898b36eab4 allow user to prevent layout render 2008-03-15 17:20:37 -07:00
Blake Mizerany ccbb070300 FIX: Render without layout 2008-02-28 00:49:09 -08:00
Blake Mizerany 7d5bc1f0da Haml & Erb redo 2008-02-27 21:07:06 -08:00
Blake Mizerany 520ac2e918 Haml 2008-02-24 01:32:52 -08:00