adamwiggins-sinatra 0.8.9 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +8 -7
 - data/CHANGES +211 -1
 - data/LICENSE +1 -1
 - data/README.rdoc +183 -139
 - data/Rakefile +20 -81
 - data/lib/sinatra.rb +5 -1
 - data/lib/sinatra/base.rb +569 -278
 - data/lib/sinatra/main.rb +12 -25
 - data/lib/sinatra/showexceptions.rb +303 -0
 - data/sinatra.gemspec +20 -44
 - data/test/base_test.rb +140 -52
 - data/test/builder_test.rb +14 -17
 - data/test/contest.rb +64 -0
 - data/test/erb_test.rb +42 -16
 - data/test/extensions_test.rb +100 -0
 - data/test/filter_test.rb +85 -13
 - data/test/haml_test.rb +39 -21
 - data/test/helper.rb +76 -0
 - data/test/helpers_test.rb +219 -84
 - data/test/mapped_error_test.rb +168 -146
 - data/test/middleware_test.rb +22 -17
 - data/test/options_test.rb +323 -54
 - data/test/render_backtrace_test.rb +145 -0
 - data/test/request_test.rb +28 -6
 - data/test/response_test.rb +42 -0
 - data/test/result_test.rb +27 -21
 - data/test/route_added_hook_test.rb +59 -0
 - data/test/routing_test.rb +558 -77
 - data/test/sass_test.rb +52 -13
 - data/test/server_test.rb +47 -0
 - data/test/sinatra_test.rb +3 -5
 - data/test/static_test.rb +57 -30
 - data/test/templates_test.rb +74 -25
 - data/test/views/error.builder +3 -0
 - data/test/views/error.erb +3 -0
 - data/test/views/error.haml +3 -0
 - data/test/views/error.sass +2 -0
 - data/test/views/foo/hello.test +1 -0
 - metadata +50 -46
 - data/compat/app_test.rb +0 -300
 - data/compat/application_test.rb +0 -334
 - data/compat/builder_test.rb +0 -101
 - data/compat/custom_error_test.rb +0 -62
 - data/compat/erb_test.rb +0 -136
 - data/compat/events_test.rb +0 -75
 - data/compat/filter_test.rb +0 -30
 - data/compat/haml_test.rb +0 -233
 - data/compat/helper.rb +0 -21
 - data/compat/mapped_error_test.rb +0 -72
 - data/compat/pipeline_test.rb +0 -71
 - data/compat/public/foo.xml +0 -1
 - data/compat/sass_test.rb +0 -57
 - data/compat/sessions_test.rb +0 -39
 - data/compat/streaming_test.rb +0 -121
 - data/compat/sym_params_test.rb +0 -19
 - data/compat/template_test.rb +0 -30
 - data/compat/use_in_file_templates_test.rb +0 -47
 - data/compat/views/foo.builder +0 -1
 - data/compat/views/foo.erb +0 -1
 - data/compat/views/foo.haml +0 -1
 - data/compat/views/foo.sass +0 -2
 - data/compat/views/foo_layout.erb +0 -2
 - data/compat/views/foo_layout.haml +0 -2
 - data/compat/views/layout_test/foo.builder +0 -1
 - data/compat/views/layout_test/foo.erb +0 -1
 - data/compat/views/layout_test/foo.haml +0 -1
 - data/compat/views/layout_test/foo.sass +0 -2
 - data/compat/views/layout_test/layout.builder +0 -3
 - data/compat/views/layout_test/layout.erb +0 -1
 - data/compat/views/layout_test/layout.haml +0 -1
 - data/compat/views/layout_test/layout.sass +0 -2
 - data/compat/views/no_layout/no_layout.builder +0 -1
 - data/compat/views/no_layout/no_layout.haml +0 -1
 - data/lib/sinatra/compat.rb +0 -239
 - data/lib/sinatra/test.rb +0 -112
 - data/lib/sinatra/test/rspec.rb +0 -2
 - data/lib/sinatra/test/spec.rb +0 -2
 - data/lib/sinatra/test/unit.rb +0 -11
 - data/test/reload_test.rb +0 -65
 
    
        data/compat/helper.rb
    DELETED
    
    | 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'mocha'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            # disable warnings in compat specs.
         
     | 
| 
       5 
     | 
    
         
            -
            $VERBOSE = nil
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            $:.unshift File.dirname(File.dirname(__FILE__)) + "/lib"
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            ENV['RACK_ENV'] ||= 'test'
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            require 'sinatra'
         
     | 
| 
       12 
     | 
    
         
            -
            require 'sinatra/test'
         
     | 
| 
       13 
     | 
    
         
            -
            require 'sinatra/test/unit'
         
     | 
| 
       14 
     | 
    
         
            -
            require 'sinatra/test/spec'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            class Test::Unit::TestCase
         
     | 
| 
       17 
     | 
    
         
            -
              def setup
         
     | 
| 
       18 
     | 
    
         
            -
                @app = lambda { |env| Sinatra::Application.call(env) }
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
              include Sinatra::Test
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/mapped_error_test.rb
    DELETED
    
    | 
         @@ -1,72 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class FooError < RuntimeError; end
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            context "Mapped errors" do
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              setup do
         
     | 
| 
       8 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       9 
     | 
    
         
            -
                Sinatra.application.options.raise_errors = false
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              specify "are rescued and run in context" do
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                error FooError do
         
     | 
| 
       15 
     | 
    
         
            -
                  'MAPPED ERROR!'
         
     | 
| 
       16 
     | 
    
         
            -
                end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       19 
     | 
    
         
            -
                  raise FooError
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                should.be.server_error
         
     | 
| 
       25 
     | 
    
         
            -
                body.should.equal 'MAPPED ERROR!'
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              specify "renders empty if no each method on result" do
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                error FooError do
         
     | 
| 
       32 
     | 
    
         
            -
                  nil
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       36 
     | 
    
         
            -
                  raise FooError
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                should.be.server_error
         
     | 
| 
       42 
     | 
    
         
            -
                body.should.be.empty
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              specify "doesn't override status if set" do
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                error FooError do
         
     | 
| 
       49 
     | 
    
         
            -
                  status(200)
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       53 
     | 
    
         
            -
                  raise FooError
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
              specify "raises errors when the raise_errors option is set" do
         
     | 
| 
       63 
     | 
    
         
            -
                Sinatra.application.options.raise_errors = true
         
     | 
| 
       64 
     | 
    
         
            -
                error FooError do
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       67 
     | 
    
         
            -
                  raise FooError
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
                assert_raises(FooError) { get_it('/') }
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/pipeline_test.rb
    DELETED
    
    | 
         @@ -1,71 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class UpcaseMiddleware
         
     | 
| 
       4 
     | 
    
         
            -
              def initialize(app, *args, &block)
         
     | 
| 
       5 
     | 
    
         
            -
                @app = app
         
     | 
| 
       6 
     | 
    
         
            -
                @args = args
         
     | 
| 
       7 
     | 
    
         
            -
                @block = block
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
              def call(env)
         
     | 
| 
       10 
     | 
    
         
            -
                env['PATH_INFO'] = env['PATH_INFO'].to_s.upcase
         
     | 
| 
       11 
     | 
    
         
            -
                @app.call(env)
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
            end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            context "Middleware Pipelines" do
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              setup do
         
     | 
| 
       18 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       19 
     | 
    
         
            -
                @app = Sinatra.application
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              teardown do
         
     | 
| 
       23 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              # Sessions and logging are tested elsewhere. This is a bad test because it
         
     | 
| 
       27 
     | 
    
         
            -
              # asserts things about the implementation and not the effect.
         
     | 
| 
       28 
     | 
    
         
            -
              xspecify "includes default middleware with options set" do
         
     | 
| 
       29 
     | 
    
         
            -
                @app.set_options :sessions => true, :logging => true
         
     | 
| 
       30 
     | 
    
         
            -
                @app.send(:optional_middleware).should.include([Rack::Session::Cookie, [], nil])
         
     | 
| 
       31 
     | 
    
         
            -
                @app.send(:optional_middleware).should.include([Rack::CommonLogger, [], nil])
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              # Bad test.
         
     | 
| 
       35 
     | 
    
         
            -
              xspecify "does not include default middleware with options unset" do
         
     | 
| 
       36 
     | 
    
         
            -
                @app.set_options :sessions => false, :logging => false
         
     | 
| 
       37 
     | 
    
         
            -
                @app.send(:optional_middleware).should.not.include([Rack::Session::Cookie, [], nil])
         
     | 
| 
       38 
     | 
    
         
            -
                @app.send(:optional_middleware).should.not.include([Rack::CommonLogger, [], nil])
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              # Bad test.
         
     | 
| 
       42 
     | 
    
         
            -
              xspecify "includes only optional middleware when no explicit middleware added" do
         
     | 
| 
       43 
     | 
    
         
            -
                @app.set_options :sessions => true, :logging => true
         
     | 
| 
       44 
     | 
    
         
            -
                @app.send(:middleware).should.equal @app.send(:optional_middleware)
         
     | 
| 
       45 
     | 
    
         
            -
              end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
              # Bad test.
         
     | 
| 
       48 
     | 
    
         
            -
              xspecify "should clear middleware before reload" do
         
     | 
| 
       49 
     | 
    
         
            -
                @app.clearables.should.include(@app.send(:explicit_middleware))
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
              specify "should add middleware with use" do
         
     | 
| 
       53 
     | 
    
         
            -
                block = Proc.new { |env| }
         
     | 
| 
       54 
     | 
    
         
            -
                @app.use UpcaseMiddleware
         
     | 
| 
       55 
     | 
    
         
            -
                @app.use UpcaseMiddleware, "foo", "bar"
         
     | 
| 
       56 
     | 
    
         
            -
                @app.use UpcaseMiddleware, "foo", "bar", &block
         
     | 
| 
       57 
     | 
    
         
            -
                @app.send(:middleware).should.include([UpcaseMiddleware, [], nil])
         
     | 
| 
       58 
     | 
    
         
            -
                @app.send(:middleware).should.include([UpcaseMiddleware, ["foo", "bar"], nil])
         
     | 
| 
       59 
     | 
    
         
            -
                @app.send(:middleware).should.include([UpcaseMiddleware, ["foo", "bar"], block])
         
     | 
| 
       60 
     | 
    
         
            -
              end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
              specify "should run middleware added with use" do
         
     | 
| 
       63 
     | 
    
         
            -
                get('/foo') { "FAIL!" }
         
     | 
| 
       64 
     | 
    
         
            -
                get('/FOO') { "PASS!" }
         
     | 
| 
       65 
     | 
    
         
            -
                use UpcaseMiddleware
         
     | 
| 
       66 
     | 
    
         
            -
                get_it '/foo'
         
     | 
| 
       67 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       68 
     | 
    
         
            -
                body.should.equal "PASS!"
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/public/foo.xml
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <foo></foo>
         
     | 
    
        data/compat/sass_test.rb
    DELETED
    
    | 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Sass" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              setup do
         
     | 
| 
       6 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              context "Templates (in general)" do
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                setup do
         
     | 
| 
       12 
     | 
    
         
            -
                  Sinatra.application = nil
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                specify "are read from files if Symbols" do
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                  get '/from_file' do
         
     | 
| 
       18 
     | 
    
         
            -
                    sass :foo, :views_directory => File.dirname(__FILE__) + "/views"
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                  get_it '/from_file'
         
     | 
| 
       22 
     | 
    
         
            -
                  should.be.ok
         
     | 
| 
       23 
     | 
    
         
            -
                  body.should.equal "#sass {\n  background_color: #FFF; }\n"
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                specify "raise an error if template not found" do
         
     | 
| 
       28 
     | 
    
         
            -
                  get '/' do
         
     | 
| 
       29 
     | 
    
         
            -
                    sass :not_found
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                  lambda { get_it '/' }.should.raise(Errno::ENOENT)
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                specify "ignore default layout file with .sass extension" do
         
     | 
| 
       36 
     | 
    
         
            -
                  get '/' do
         
     | 
| 
       37 
     | 
    
         
            -
                    sass :foo, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  get_it '/'
         
     | 
| 
       41 
     | 
    
         
            -
                  should.be.ok
         
     | 
| 
       42 
     | 
    
         
            -
                  body.should.equal "#sass {\n  background_color: #FFF; }\n"
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                specify "ignore explicitly specified layout file" do
         
     | 
| 
       46 
     | 
    
         
            -
                  get '/' do
         
     | 
| 
       47 
     | 
    
         
            -
                    sass :foo, :layout => :layout, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
         
     | 
| 
       48 
     | 
    
         
            -
                  end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  get_it '/'
         
     | 
| 
       51 
     | 
    
         
            -
                  should.be.ok
         
     | 
| 
       52 
     | 
    
         
            -
                  body.should.equal "#sass {\n  background_color: #FFF; }\n"
         
     | 
| 
       53 
     | 
    
         
            -
                end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/sessions_test.rb
    DELETED
    
    | 
         @@ -1,39 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Sessions" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              setup { Sinatra.application = nil }
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              specify "should be off by default" do
         
     | 
| 
       8 
     | 
    
         
            -
                get '/asdf' do
         
     | 
| 
       9 
     | 
    
         
            -
                  session[:test] = true
         
     | 
| 
       10 
     | 
    
         
            -
                  "asdf"
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                get '/test' do
         
     | 
| 
       14 
     | 
    
         
            -
                  session[:test] == true ? "true" : "false"
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                get_it '/asdf', {}, 'HTTP_HOST' => 'foo.sinatrarb.com'
         
     | 
| 
       18 
     | 
    
         
            -
                assert ok?
         
     | 
| 
       19 
     | 
    
         
            -
                assert !include?('Set-Cookie')
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              specify "should be able to store data accross requests" do
         
     | 
| 
       23 
     | 
    
         
            -
                set_option :sessions, true
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                get '/foo' do
         
     | 
| 
       26 
     | 
    
         
            -
                  session[:test] = true
         
     | 
| 
       27 
     | 
    
         
            -
                  "asdf"
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                get '/bar' do
         
     | 
| 
       31 
     | 
    
         
            -
                  session[:test] == true ? "true" : "false"
         
     | 
| 
       32 
     | 
    
         
            -
                end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
         
     | 
| 
       35 
     | 
    
         
            -
                assert ok?
         
     | 
| 
       36 
     | 
    
         
            -
                assert include?('Set-Cookie')
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/streaming_test.rb
    DELETED
    
    | 
         @@ -1,121 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Static files (by default)" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              setup do
         
     | 
| 
       6 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       7 
     | 
    
         
            -
                Sinatra.application.options.public = File.dirname(__FILE__) + '/public'
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              specify "are served from root/public" do
         
     | 
| 
       11 
     | 
    
         
            -
                get_it '/foo.xml'
         
     | 
| 
       12 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       13 
     | 
    
         
            -
                headers['Content-Length'].should.equal '12'
         
     | 
| 
       14 
     | 
    
         
            -
                headers['Content-Type'].should.equal 'application/xml'
         
     | 
| 
       15 
     | 
    
         
            -
                body.should.equal "<foo></foo>\n"
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              specify "are not served when verb is not GET or HEAD" do
         
     | 
| 
       19 
     | 
    
         
            -
                post_it '/foo.xml'
         
     | 
| 
       20 
     | 
    
         
            -
                # these should actually be giving back a 405 Method Not Allowed but that
         
     | 
| 
       21 
     | 
    
         
            -
                # complicates the routing logic quite a bit.
         
     | 
| 
       22 
     | 
    
         
            -
                should.be.not_found
         
     | 
| 
       23 
     | 
    
         
            -
                status.should.equal 404
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              specify "are served when verb is HEAD but missing a body" do
         
     | 
| 
       27 
     | 
    
         
            -
                head_it '/foo.xml'
         
     | 
| 
       28 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       29 
     | 
    
         
            -
                headers['Content-Length'].should.equal '12'
         
     | 
| 
       30 
     | 
    
         
            -
                headers['Content-Type'].should.equal 'application/xml'
         
     | 
| 
       31 
     | 
    
         
            -
                body.should.equal ""
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              # static files override dynamic/internal events and ...
         
     | 
| 
       35 
     | 
    
         
            -
              specify "are served when conflicting events exists" do
         
     | 
| 
       36 
     | 
    
         
            -
                get '/foo.xml' do
         
     | 
| 
       37 
     | 
    
         
            -
                  'this is not foo.xml!'
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
                get_it '/foo.xml'
         
     | 
| 
       40 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       41 
     | 
    
         
            -
                body.should.equal "<foo></foo>\n"
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              specify "are irrelevant when request_method is not GET/HEAD" do
         
     | 
| 
       45 
     | 
    
         
            -
                put '/foo.xml' do
         
     | 
| 
       46 
     | 
    
         
            -
                  'putted!'
         
     | 
| 
       47 
     | 
    
         
            -
                end
         
     | 
| 
       48 
     | 
    
         
            -
                put_it '/foo.xml'
         
     | 
| 
       49 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       50 
     | 
    
         
            -
                body.should.equal 'putted!'
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                get_it '/foo.xml'
         
     | 
| 
       53 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       54 
     | 
    
         
            -
                body.should.equal "<foo></foo>\n"
         
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
              specify "include a Last-Modified header" do
         
     | 
| 
       58 
     | 
    
         
            -
                last_modified = File.mtime(Sinatra.application.options.public + '/foo.xml')
         
     | 
| 
       59 
     | 
    
         
            -
                get_it('/foo.xml')
         
     | 
| 
       60 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       61 
     | 
    
         
            -
                body.should.not.be.empty
         
     | 
| 
       62 
     | 
    
         
            -
                headers['Last-Modified'].should.equal last_modified.httpdate
         
     | 
| 
       63 
     | 
    
         
            -
              end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
              # Deprecated. Use: ConditionalGet middleware.
         
     | 
| 
       66 
     | 
    
         
            -
              specify "are not served when If-Modified-Since matches" do
         
     | 
| 
       67 
     | 
    
         
            -
                last_modified = File.mtime(Sinatra.application.options.public + '/foo.xml')
         
     | 
| 
       68 
     | 
    
         
            -
                @request = Rack::MockRequest.new(Sinatra.application)
         
     | 
| 
       69 
     | 
    
         
            -
                @response = @request.get('/foo.xml', 'HTTP_IF_MODIFIED_SINCE' => last_modified.httpdate)
         
     | 
| 
       70 
     | 
    
         
            -
                status.should.equal 304
         
     | 
| 
       71 
     | 
    
         
            -
                body.should.be.empty
         
     | 
| 
       72 
     | 
    
         
            -
              end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
              specify "should omit Content-Disposition headers" do
         
     | 
| 
       75 
     | 
    
         
            -
                get_it('/foo.xml')
         
     | 
| 
       76 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       77 
     | 
    
         
            -
                headers['Content-Disposition'].should.be.nil
         
     | 
| 
       78 
     | 
    
         
            -
                headers['Content-Transfer-Encoding'].should.be.nil
         
     | 
| 
       79 
     | 
    
         
            -
              end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
              specify "should be served even if their path is url escaped" do
         
     | 
| 
       82 
     | 
    
         
            -
            	get_it('/fo%6f.xml')
         
     | 
| 
       83 
     | 
    
         
            -
            	should.be.ok
         
     | 
| 
       84 
     | 
    
         
            -
                body.should.equal "<foo></foo>\n"
         
     | 
| 
       85 
     | 
    
         
            -
              end
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
            end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            context "SendData" do
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
              setup do
         
     | 
| 
       92 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              # Deprecated. send_data is going away.
         
     | 
| 
       96 
     | 
    
         
            -
              xspecify "should send the data with options" do
         
     | 
| 
       97 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       98 
     | 
    
         
            -
                  send_data 'asdf', :status => 500
         
     | 
| 
       99 
     | 
    
         
            -
                end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                should.be.server_error
         
     | 
| 
       104 
     | 
    
         
            -
                body.should.equal 'asdf'
         
     | 
| 
       105 
     | 
    
         
            -
              end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
              # Deprecated. The Content-Disposition is no longer handled by sendfile.
         
     | 
| 
       108 
     | 
    
         
            -
              specify "should include a Content-Disposition header" do
         
     | 
| 
       109 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       110 
     | 
    
         
            -
                  send_file File.dirname(__FILE__) + '/public/foo.xml'
         
     | 
| 
       111 
     | 
    
         
            -
                end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       116 
     | 
    
         
            -
                headers['Content-Disposition'].should.not.be.nil
         
     | 
| 
       117 
     | 
    
         
            -
                headers['Content-Disposition'].should.equal 'attachment; filename="foo.xml"'
         
     | 
| 
       118 
     | 
    
         
            -
                headers['Content-Transfer-Encoding'].should.equal 'binary'
         
     | 
| 
       119 
     | 
    
         
            -
              end
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
            end
         
     | 
    
        data/compat/sym_params_test.rb
    DELETED
    
    | 
         @@ -1,19 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Symbol Params" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              setup do
         
     | 
| 
       6 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              specify "should be accessable as Strings or Symbols" do
         
     | 
| 
       10 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       11 
     | 
    
         
            -
                  params[:foo] + params['foo']
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                get_it '/', :foo => "X"
         
     | 
| 
       15 
     | 
    
         
            -
                assert_equal('XX', body)
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
    
        data/compat/template_test.rb
    DELETED
    
    | 
         @@ -1,30 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Templates" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              specify "are read from files if Symbols" do
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                get '/from_file' do
         
     | 
| 
       8 
     | 
    
         
            -
                  @name = 'Alena'
         
     | 
| 
       9 
     | 
    
         
            -
                  erb :foo, :views_directory => File.dirname(__FILE__) + "/views"
         
     | 
| 
       10 
     | 
    
         
            -
                end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                get_it '/from_file'
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                body.should.equal 'You rock Alena!'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              specify "use layout.ext by default if available" do
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                get '/layout_from_file' do
         
     | 
| 
       21 
     | 
    
         
            -
                  erb :foo, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                get_it '/layout_from_file'
         
     | 
| 
       25 
     | 
    
         
            -
                should.be.ok
         
     | 
| 
       26 
     | 
    
         
            -
                body.should.equal "x This is foo! x \n"
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,47 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            context "Rendering in file templates" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              setup do
         
     | 
| 
       6 
     | 
    
         
            -
                Sinatra.application = nil
         
     | 
| 
       7 
     | 
    
         
            -
                use_in_file_templates!
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              specify "should set template" do
         
     | 
| 
       11 
     | 
    
         
            -
                assert Sinatra.application.templates[:foo]
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              specify "should set layout" do
         
     | 
| 
       15 
     | 
    
         
            -
                assert Sinatra.application.templates[:layout]
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              specify "should render without layout if specified" do
         
     | 
| 
       19 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       20 
     | 
    
         
            -
                  haml :foo, :layout => false
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       24 
     | 
    
         
            -
                assert_equal "this is foo\n", body
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              specify "should render with layout if specified" do
         
     | 
| 
       28 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       29 
     | 
    
         
            -
                  haml :foo
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                get_it '/'
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal "X\nthis is foo\nX\n", body
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
            __END__
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            @@ foo
         
     | 
| 
       41 
     | 
    
         
            -
            this is foo
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            @@ layout
         
     | 
| 
       44 
     | 
    
         
            -
            X
         
     | 
| 
       45 
     | 
    
         
            -
            = yield
         
     | 
| 
       46 
     | 
    
         
            -
            X
         
     | 
| 
       47 
     | 
    
         
            -
             
     |