roda 2.2.0 → 2.3.0
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.
- checksums.yaml +4 -4
 - data/CHANGELOG +34 -0
 - data/Rakefile +22 -46
 - data/doc/release_notes/2.3.0.txt +109 -0
 - data/lib/roda/plugins/assets.rb +2 -1
 - data/lib/roda/plugins/caching.rb +1 -1
 - data/lib/roda/plugins/chunked.rb +1 -1
 - data/lib/roda/plugins/error_email.rb +1 -1
 - data/lib/roda/plugins/head.rb +6 -0
 - data/lib/roda/plugins/heartbeat.rb +40 -0
 - data/lib/roda/plugins/json.rb +23 -3
 - data/lib/roda/plugins/json_parser.rb +72 -0
 - data/lib/roda/plugins/mailer.rb +22 -5
 - data/lib/roda/plugins/named_templates.rb +2 -2
 - data/lib/roda/plugins/path_rewriter.rb +82 -0
 - data/lib/roda/plugins/precompile_templates.rb +87 -0
 - data/lib/roda/plugins/render.rb +111 -43
 - data/lib/roda/plugins/render_each.rb +1 -1
 - data/lib/roda/plugins/shared_vars.rb +1 -1
 - data/lib/roda/plugins/view_options.rb +28 -3
 - data/lib/roda/version.rb +1 -1
 - data/spec/composition_spec.rb +3 -3
 - data/spec/env_spec.rb +1 -1
 - data/spec/freeze_spec.rb +6 -6
 - data/spec/integration_spec.rb +16 -15
 - data/spec/matchers_spec.rb +110 -110
 - data/spec/opts_spec.rb +8 -8
 - data/spec/plugin/_erubis_escaping_spec.rb +34 -3
 - data/spec/plugin/all_verbs_spec.rb +8 -8
 - data/spec/plugin/assets_spec.rb +164 -150
 - data/spec/plugin/backtracking_array_spec.rb +18 -18
 - data/spec/plugin/caching_spec.rb +70 -70
 - data/spec/plugin/chunked_spec.rb +38 -38
 - data/spec/plugin/class_level_routing_spec.rb +78 -78
 - data/spec/plugin/content_for_spec.rb +2 -2
 - data/spec/plugin/cookies_spec.rb +4 -4
 - data/spec/plugin/csrf_spec.rb +8 -8
 - data/spec/plugin/default_headers_spec.rb +6 -6
 - data/spec/plugin/delay_build_spec.rb +7 -6
 - data/spec/plugin/delegate_spec.rb +2 -2
 - data/spec/plugin/delete_empty_headers_spec.rb +2 -2
 - data/spec/plugin/drop_body_spec.rb +6 -6
 - data/spec/plugin/empty_root_spec.rb +3 -3
 - data/spec/plugin/environments_spec.rb +7 -7
 - data/spec/plugin/error_email_spec.rb +23 -23
 - data/spec/plugin/error_handler_spec.rb +14 -14
 - data/spec/plugin/flash_spec.rb +30 -29
 - data/spec/plugin/h_spec.rb +1 -1
 - data/spec/plugin/halt_spec.rb +16 -16
 - data/spec/plugin/hash_matcher_spec.rb +5 -5
 - data/spec/plugin/head_spec.rb +10 -10
 - data/spec/plugin/header_matchers_spec.rb +13 -13
 - data/spec/plugin/heartbeat_spec.rb +74 -0
 - data/spec/plugin/hooks_spec.rb +20 -20
 - data/spec/plugin/indifferent_params_spec.rb +1 -1
 - data/spec/plugin/json_parser_spec.rb +72 -0
 - data/spec/plugin/json_spec.rb +22 -9
 - data/spec/plugin/mailer_spec.rb +72 -58
 - data/spec/plugin/match_affix_spec.rb +2 -2
 - data/spec/plugin/middleware_spec.rb +7 -7
 - data/spec/plugin/module_include_spec.rb +4 -4
 - data/spec/plugin/multi_route_spec.rb +66 -66
 - data/spec/plugin/multi_run_spec.rb +21 -21
 - data/spec/plugin/named_templates_spec.rb +6 -6
 - data/spec/plugin/not_allowed_spec.rb +17 -17
 - data/spec/plugin/not_found_spec.rb +14 -14
 - data/spec/plugin/padrino_render_spec.rb +2 -2
 - data/spec/plugin/param_matchers_spec.rb +6 -6
 - data/spec/plugin/partials_spec.rb +3 -3
 - data/spec/plugin/pass_spec.rb +7 -7
 - data/spec/plugin/path_matchers_spec.rb +6 -6
 - data/spec/plugin/path_rewriter_spec.rb +37 -0
 - data/spec/plugin/path_spec.rb +41 -40
 - data/spec/plugin/per_thread_caching_spec.rb +6 -6
 - data/spec/plugin/precompile_templates_spec.rb +74 -0
 - data/spec/plugin/render_each_spec.rb +4 -4
 - data/spec/plugin/render_spec.rb +179 -76
 - data/spec/plugin/shared_vars_spec.rb +4 -4
 - data/spec/plugin/sinatra_helpers_spec.rb +121 -121
 - data/spec/plugin/slash_path_empty_spec.rb +10 -10
 - data/spec/plugin/static_spec.rb +4 -4
 - data/spec/plugin/streaming_spec.rb +11 -11
 - data/spec/plugin/symbol_matchers_spec.rb +24 -24
 - data/spec/plugin/symbol_views_spec.rb +3 -3
 - data/spec/plugin/view_options_spec.rb +10 -10
 - data/spec/plugin_spec.rb +2 -2
 - data/spec/redirect_spec.rb +10 -10
 - data/spec/request_spec.rb +8 -8
 - data/spec/response_spec.rb +23 -23
 - data/spec/session_spec.rb +4 -4
 - data/spec/spec_helper.rb +5 -19
 - data/spec/version_spec.rb +4 -4
 - data/spec/views/iv.erb +1 -0
 - metadata +16 -5
 
| 
         @@ -32,10 +32,10 @@ describe "render_each plugin" do 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                body. 
     | 
| 
       36 
     | 
    
         
            -
                body("/a"). 
     | 
| 
       37 
     | 
    
         
            -
                body("/b"). 
     | 
| 
       38 
     | 
    
         
            -
                body("/c"). 
     | 
| 
      
 35 
     | 
    
         
            +
                body.must_equal 'rfoo1 rfoo2 rfoo3 '
         
     | 
| 
      
 36 
     | 
    
         
            +
                body("/a").must_equal 'rbar14 rbar24 rbar34 '
         
     | 
| 
      
 37 
     | 
    
         
            +
                body("/b").must_equal 'rbar rbar rbar '
         
     | 
| 
      
 38 
     | 
    
         
            +
                body("/c").must_equal 'rbar41 rbar42 rbar43 '
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
       40 
40 
     | 
    
         
             
            end
         
     | 
| 
       41 
41 
     | 
    
         
             
            end
         
     | 
    
        data/spec/plugin/render_spec.rb
    CHANGED
    
    | 
         @@ -36,35 +36,35 @@ describe "render plugin" do 
     | 
|
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
              it "default actions" do
         
     | 
| 
       39 
     | 
    
         
            -
                body("/about").strip. 
     | 
| 
       40 
     | 
    
         
            -
                body("/home").strip. 
     | 
| 
       41 
     | 
    
         
            -
                body("/inline").strip. 
     | 
| 
       42 
     | 
    
         
            -
                body("/path").strip. 
     | 
| 
       43 
     | 
    
         
            -
                body("/content").strip. 
     | 
| 
      
 39 
     | 
    
         
            +
                body("/about").strip.must_equal "<h1>About Roda</h1>"
         
     | 
| 
      
 40 
     | 
    
         
            +
                body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
      
 41 
     | 
    
         
            +
                body("/inline").strip.must_equal "Hello Agent Smith"
         
     | 
| 
      
 42 
     | 
    
         
            +
                body("/path").strip.must_equal "<h1>Path</h1>"
         
     | 
| 
      
 43 
     | 
    
         
            +
                body("/content").strip.must_equal "<title>Roda: Home</title>\nbar"
         
     | 
| 
       44 
44 
     | 
    
         
             
              end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
              it "with str as engine" do
         
     | 
| 
       47 
47 
     | 
    
         
             
                app.plugin :render, :engine => "str"
         
     | 
| 
       48 
     | 
    
         
            -
                body("/about").strip. 
     | 
| 
       49 
     | 
    
         
            -
                body("/home").strip. 
     | 
| 
       50 
     | 
    
         
            -
                body("/inline").strip. 
     | 
| 
      
 48 
     | 
    
         
            +
                body("/about").strip.must_equal "<h1>About Roda</h1>"
         
     | 
| 
      
 49 
     | 
    
         
            +
                body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
      
 50 
     | 
    
         
            +
                body("/inline").strip.must_equal "Hello <%= name %>"
         
     | 
| 
       51 
51 
     | 
    
         
             
              end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
              it "with str as ext" do
         
     | 
| 
       54 
54 
     | 
    
         
             
                app.plugin :render, :ext => "str"
         
     | 
| 
       55 
     | 
    
         
            -
                body("/about").strip. 
     | 
| 
       56 
     | 
    
         
            -
                body("/home").strip. 
     | 
| 
       57 
     | 
    
         
            -
                body("/inline").strip. 
     | 
| 
      
 55 
     | 
    
         
            +
                body("/about").strip.must_equal "<h1>About Roda</h1>"
         
     | 
| 
      
 56 
     | 
    
         
            +
                body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
      
 57 
     | 
    
         
            +
                body("/inline").strip.must_equal "Hello <%= name %>" 
         
     | 
| 
       58 
58 
     | 
    
         
             
              end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
60 
     | 
    
         
             
              it "custom default layout support" do
         
     | 
| 
       61 
61 
     | 
    
         
             
                app.plugin :render, :layout => "layout-alternative"
         
     | 
| 
       62 
     | 
    
         
            -
                body("/home").strip. 
     | 
| 
      
 62 
     | 
    
         
            +
                body("/home").strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
       63 
63 
     | 
    
         
             
              end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
              it "using hash for :layout" do
         
     | 
| 
       66 
66 
     | 
    
         
             
                app.plugin :render, :layout => {:inline=> 'a<%= yield %>b'}
         
     | 
| 
       67 
     | 
    
         
            -
                body("/home").strip. 
     | 
| 
      
 67 
     | 
    
         
            +
                body("/home").strip.must_equal "a<h1>Home</h1>\n<p>Hello Agent Smith</p>\nb"
         
     | 
| 
       68 
68 
     | 
    
         
             
              end
         
     | 
| 
       69 
69 
     | 
    
         
             
            end
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
         @@ -80,7 +80,7 @@ describe "render plugin" do 
     | 
|
| 
       80 
80 
     | 
    
         
             
                  end
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                body.gsub(/\n+/, "\n"). 
     | 
| 
      
 83 
     | 
    
         
            +
                body.gsub(/\n+/, "\n").must_equal "Header\nThis is the actual content.\nFooter\n"
         
     | 
| 
       84 
84 
     | 
    
         
             
              end
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
              it "views without default layouts" do
         
     | 
| 
         @@ -92,7 +92,7 @@ describe "render plugin" do 
     | 
|
| 
       92 
92 
     | 
    
         
             
                  end
         
     | 
| 
       93 
93 
     | 
    
         
             
                end
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 95 
     | 
    
         
            +
                body.strip.must_equal "<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
              it "layout overrides" do
         
     | 
| 
         @@ -104,7 +104,7 @@ describe "render plugin" do 
     | 
|
| 
       104 
104 
     | 
    
         
             
                  end
         
     | 
| 
       105 
105 
     | 
    
         
             
                end
         
     | 
| 
       106 
106 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 107 
     | 
    
         
            +
                body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
         
     | 
| 
       108 
108 
     | 
    
         
             
              end
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
110 
     | 
    
         
             
              it "locals overrides" do
         
     | 
| 
         @@ -116,7 +116,7 @@ describe "render plugin" do 
     | 
|
| 
       116 
116 
     | 
    
         
             
                  end
         
     | 
| 
       117 
117 
     | 
    
         
             
                end
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 119 
     | 
    
         
            +
                body.strip.must_equal "Roda:AA::Home:BB"
         
     | 
| 
       120 
120 
     | 
    
         
             
              end
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
122 
     | 
    
         
             
              it ":layout=>true/false/string/hash/not-present respects plugin layout switch and template" do
         
     | 
| 
         @@ -133,73 +133,73 @@ describe "render plugin" do 
     | 
|
| 
       133 
133 
     | 
    
         
             
                  end
         
     | 
| 
       134 
134 
     | 
    
         
             
                end
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       137 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       138 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       139 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       140 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 136 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 137 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 138 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 139 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 140 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       141 
141 
     | 
    
         | 
| 
       142 
142 
     | 
    
         
             
                app.plugin :render
         
     | 
| 
       143 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       144 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       145 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       146 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       147 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 143 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 144 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 145 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 146 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 147 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
149 
     | 
    
         
             
                app.plugin :render, :layout=>true
         
     | 
| 
       150 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       151 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       152 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       153 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       154 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 150 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 151 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 152 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 153 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 154 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       155 
155 
     | 
    
         | 
| 
       156 
156 
     | 
    
         
             
                app.plugin :render, :layout=>'layout-alternative'
         
     | 
| 
       157 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       158 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       159 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       160 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       161 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 157 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
         
     | 
| 
      
 158 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
         
     | 
| 
      
 159 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 160 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 161 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       162 
162 
     | 
    
         | 
| 
       163 
163 
     | 
    
         
             
                app.plugin :render, :layout=>nil
         
     | 
| 
       164 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       165 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       166 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       167 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       168 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 164 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 165 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 166 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 167 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 168 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       169 
169 
     | 
    
         | 
| 
       170 
170 
     | 
    
         
             
                app.plugin :render, :layout=>false
         
     | 
| 
       171 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       172 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       173 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       174 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       175 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 171 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "HeaderbarFooter"
         
     | 
| 
      
 172 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 173 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 174 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 175 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       176 
176 
     | 
    
         | 
| 
       177 
177 
     | 
    
         
             
                app.plugin :render, :layout_opts=>{:template=>'layout-alternative', :locals=>{:title=>'a'}}
         
     | 
| 
       178 
     | 
    
         
            -
                body.gsub("\n", ''). 
     | 
| 
       179 
     | 
    
         
            -
                body('/a').gsub("\n", ''). 
     | 
| 
       180 
     | 
    
         
            -
                body('/f').gsub("\n", ''). 
     | 
| 
       181 
     | 
    
         
            -
                body('/s').gsub("\n", ''). 
     | 
| 
       182 
     | 
    
         
            -
                body('/h').gsub("\n", ''). 
     | 
| 
      
 178 
     | 
    
         
            +
                body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
         
     | 
| 
      
 179 
     | 
    
         
            +
                body('/a').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 180 
     | 
    
         
            +
                body('/f').gsub("\n", '').must_equal "bar"
         
     | 
| 
      
 181 
     | 
    
         
            +
                body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
      
 182 
     | 
    
         
            +
                body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
         
     | 
| 
       183 
183 
     | 
    
         
             
              end
         
     | 
| 
       184 
184 
     | 
    
         | 
| 
       185 
185 
     | 
    
         
             
              it "app :root option affects :views default" do
         
     | 
| 
       186 
186 
     | 
    
         
             
                app
         
     | 
| 
       187 
187 
     | 
    
         
             
                app.plugin :render
         
     | 
| 
       188 
     | 
    
         
            -
                app.render_opts[:views]. 
     | 
| 
      
 188 
     | 
    
         
            +
                app.render_opts[:views].must_equal File.join(Dir.pwd, 'views')
         
     | 
| 
       189 
189 
     | 
    
         | 
| 
       190 
190 
     | 
    
         
             
                app.opts[:root] = '/foo'
         
     | 
| 
       191 
191 
     | 
    
         
             
                app.plugin :render
         
     | 
| 
       192 
     | 
    
         
            -
                app.render_opts[:views]. 
     | 
| 
      
 192 
     | 
    
         
            +
                app.render_opts[:views].must_equal '/foo/views'
         
     | 
| 
       193 
193 
     | 
    
         | 
| 
       194 
194 
     | 
    
         
             
                app.opts[:root] = '/foo/bar'
         
     | 
| 
       195 
195 
     | 
    
         
             
                app.plugin :render
         
     | 
| 
       196 
     | 
    
         
            -
                app.render_opts[:views]. 
     | 
| 
      
 196 
     | 
    
         
            +
                app.render_opts[:views].must_equal '/foo/bar/views'
         
     | 
| 
       197 
197 
     | 
    
         | 
| 
       198 
198 
     | 
    
         
             
                app.opts[:root] = nil
         
     | 
| 
       199 
199 
     | 
    
         
             
                app.plugin :render
         
     | 
| 
       200 
     | 
    
         
            -
                app.render_opts[:views]. 
     | 
| 
      
 200 
     | 
    
         
            +
                app.render_opts[:views].must_equal File.join(Dir.pwd, 'views')
         
     | 
| 
       201 
201 
     | 
    
         
             
                app.plugin :render, :views=>'bar'
         
     | 
| 
       202 
     | 
    
         
            -
                app.render_opts[:views]. 
     | 
| 
      
 202 
     | 
    
         
            +
                app.render_opts[:views].must_equal File.join(Dir.pwd, 'bar')
         
     | 
| 
       203 
203 
     | 
    
         
             
              end
         
     | 
| 
       204 
204 
     | 
    
         | 
| 
       205 
205 
     | 
    
         
             
              it "inline layouts and inline views" do
         
     | 
| 
         @@ -207,7 +207,7 @@ describe "render plugin" do 
     | 
|
| 
       207 
207 
     | 
    
         
             
                  view({:inline=>'bar'}, :layout=>{:inline=>'Foo: <%= yield %>'})
         
     | 
| 
       208 
208 
     | 
    
         
             
                end
         
     | 
| 
       209 
209 
     | 
    
         | 
| 
       210 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 210 
     | 
    
         
            +
                body.strip.must_equal "Foo: bar"
         
     | 
| 
       211 
211 
     | 
    
         
             
              end
         
     | 
| 
       212 
212 
     | 
    
         | 
| 
       213 
213 
     | 
    
         
             
              it "inline renders with opts" do
         
     | 
| 
         @@ -215,7 +215,7 @@ describe "render plugin" do 
     | 
|
| 
       215 
215 
     | 
    
         
             
                  render({:inline=>'<%= bar %>'}, {:engine=>'str'})
         
     | 
| 
       216 
216 
     | 
    
         
             
                end
         
     | 
| 
       217 
217 
     | 
    
         | 
| 
       218 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 218 
     | 
    
         
            +
                body.strip.must_equal '<%= bar %>'
         
     | 
| 
       219 
219 
     | 
    
         
             
              end
         
     | 
| 
       220 
220 
     | 
    
         | 
| 
       221 
221 
     | 
    
         
             
              it "template renders with :template opts" do
         
     | 
| 
         @@ -225,7 +225,7 @@ describe "render plugin" do 
     | 
|
| 
       225 
225 
     | 
    
         
             
                    render(:template=>"about", :locals=>{:title => "About Roda"})
         
     | 
| 
       226 
226 
     | 
    
         
             
                  end
         
     | 
| 
       227 
227 
     | 
    
         
             
                end
         
     | 
| 
       228 
     | 
    
         
            -
                body.strip. 
     | 
| 
      
 228 
     | 
    
         
            +
                body.strip.must_equal "<h1>About Roda</h1>"
         
     | 
| 
       229 
229 
     | 
    
         
             
              end
         
     | 
| 
       230 
230 
     | 
    
         | 
| 
       231 
231 
     | 
    
         
             
              it "template renders with :template_class opts" do
         
     | 
| 
         @@ -233,7 +233,22 @@ describe "render plugin" do 
     | 
|
| 
       233 
233 
     | 
    
         
             
                  @a = 1
         
     | 
| 
       234 
234 
     | 
    
         
             
                  render(:inline=>'i#{@a}', :template_class=>::Tilt[:str])
         
     | 
| 
       235 
235 
     | 
    
         
             
                end
         
     | 
| 
       236 
     | 
    
         
            -
                body. 
     | 
| 
      
 236 
     | 
    
         
            +
                body.must_equal "i1"
         
     | 
| 
      
 237 
     | 
    
         
            +
              end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
              it "can specify engine-specific options via :engine_opts" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                app(:bare) do
         
     | 
| 
      
 241 
     | 
    
         
            +
                  plugin :render, :engine_opts=>{'a.erb'=>{:outvar=>'@a'}}
         
     | 
| 
      
 242 
     | 
    
         
            +
                  route do |r|
         
     | 
| 
      
 243 
     | 
    
         
            +
                    r.is('a') do
         
     | 
| 
      
 244 
     | 
    
         
            +
                      render(:inline=>'<%= @a.class.name %>', :engine=>'a.erb')
         
     | 
| 
      
 245 
     | 
    
         
            +
                    end
         
     | 
| 
      
 246 
     | 
    
         
            +
                    render(:inline=>'<%= @a.class.name %>')
         
     | 
| 
      
 247 
     | 
    
         
            +
                  end
         
     | 
| 
      
 248 
     | 
    
         
            +
                end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                body('/a').must_equal "String"
         
     | 
| 
      
 251 
     | 
    
         
            +
                body.must_equal "NilClass"
         
     | 
| 
       237 
252 
     | 
    
         
             
              end
         
     | 
| 
       238 
253 
     | 
    
         | 
| 
       239 
254 
     | 
    
         
             
              it "template cache respects :template_opts" do
         
     | 
| 
         @@ -256,32 +271,120 @@ describe "render plugin" do 
     | 
|
| 
       256 
271 
     | 
    
         
             
                  end
         
     | 
| 
       257 
272 
     | 
    
         
             
                end
         
     | 
| 
       258 
273 
     | 
    
         | 
| 
       259 
     | 
    
         
            -
                body('/a'). 
     | 
| 
       260 
     | 
    
         
            -
                body('/b'). 
     | 
| 
      
 274 
     | 
    
         
            +
                body('/a').must_equal "i-a"
         
     | 
| 
      
 275 
     | 
    
         
            +
                body('/b').must_equal "i-b"
         
     | 
| 
       261 
276 
     | 
    
         
             
              end
         
     | 
| 
       262 
277 
     | 
    
         | 
| 
       263 
     | 
    
         
            -
              it "template cache respects : 
     | 
| 
      
 278 
     | 
    
         
            +
              it "template cache respects :template_block" do
         
     | 
| 
       264 
279 
     | 
    
         
             
                c = Class.new do 
         
     | 
| 
       265 
     | 
    
         
            -
                  def initialize(path,  
     | 
| 
      
 280 
     | 
    
         
            +
                  def initialize(path, *, &block)
         
     | 
| 
       266 
281 
     | 
    
         
             
                    @path = path
         
     | 
| 
       267 
     | 
    
         
            -
                    @ 
     | 
| 
      
 282 
     | 
    
         
            +
                    @block = block
         
     | 
| 
       268 
283 
     | 
    
         
             
                  end
         
     | 
| 
       269 
284 
     | 
    
         
             
                  def render(*)
         
     | 
| 
       270 
     | 
    
         
            -
                    "#{@path}-#{@ 
     | 
| 
      
 285 
     | 
    
         
            +
                    "#{@path}-#{@block.call}"
         
     | 
| 
      
 286 
     | 
    
         
            +
                  end
         
     | 
| 
      
 287 
     | 
    
         
            +
                end 
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                proca = proc{'a'}
         
     | 
| 
      
 290 
     | 
    
         
            +
                procb = proc{'b'}
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
                app(:render) do |r|
         
     | 
| 
      
 293 
     | 
    
         
            +
                  r.is "a" do
         
     | 
| 
      
 294 
     | 
    
         
            +
                    render(:path=>"i", :template_class=>c, :template_block=>proca)
         
     | 
| 
      
 295 
     | 
    
         
            +
                  end
         
     | 
| 
      
 296 
     | 
    
         
            +
                  r.is "b" do
         
     | 
| 
      
 297 
     | 
    
         
            +
                    render(:path=>"i", :template_class=>c, :template_block=>procb)
         
     | 
| 
       271 
298 
     | 
    
         
             
                  end
         
     | 
| 
       272 
299 
     | 
    
         
             
                end
         
     | 
| 
       273 
300 
     | 
    
         | 
| 
      
 301 
     | 
    
         
            +
                body('/a').must_equal "i-a"
         
     | 
| 
      
 302 
     | 
    
         
            +
                body('/b').must_equal "i-b"
         
     | 
| 
      
 303 
     | 
    
         
            +
              end
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
              it "template cache respects :locals" do
         
     | 
| 
      
 306 
     | 
    
         
            +
                template = '<%= @a ? b : c %>'
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
       274 
308 
     | 
    
         
             
                app(:render) do |r|
         
     | 
| 
       275 
309 
     | 
    
         
             
                  r.is "a" do
         
     | 
| 
       276 
     | 
    
         
            -
                     
     | 
| 
      
 310 
     | 
    
         
            +
                    @a = true
         
     | 
| 
      
 311 
     | 
    
         
            +
                    render(:inline=>template.dup, :locals=>{:b=>1})
         
     | 
| 
       277 
312 
     | 
    
         
             
                  end
         
     | 
| 
       278 
313 
     | 
    
         
             
                  r.is "b" do
         
     | 
| 
       279 
     | 
    
         
            -
                     
     | 
| 
      
 314 
     | 
    
         
            +
                    @a = true
         
     | 
| 
      
 315 
     | 
    
         
            +
                    render(:inline=>template.dup, :locals=>{:b=>2, :c=>4})
         
     | 
| 
      
 316 
     | 
    
         
            +
                  end
         
     | 
| 
      
 317 
     | 
    
         
            +
                  r.is "c" do
         
     | 
| 
      
 318 
     | 
    
         
            +
                    render(:inline=>template.dup, :locals=>{:c=>3})
         
     | 
| 
      
 319 
     | 
    
         
            +
                  end
         
     | 
| 
      
 320 
     | 
    
         
            +
                end
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                body('/a').must_equal "1"
         
     | 
| 
      
 323 
     | 
    
         
            +
                body('/b').must_equal "2"
         
     | 
| 
      
 324 
     | 
    
         
            +
                body('/c').must_equal "3"
         
     | 
| 
      
 325 
     | 
    
         
            +
              end
         
     | 
| 
      
 326 
     | 
    
         
            +
             
     | 
| 
      
 327 
     | 
    
         
            +
              it "Support :cache=>false option to disable template caching" do
         
     | 
| 
      
 328 
     | 
    
         
            +
                app(:bare) do
         
     | 
| 
      
 329 
     | 
    
         
            +
                  plugin :render, :views=>"./spec/views"
         
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
      
 331 
     | 
    
         
            +
                  route do |r|
         
     | 
| 
      
 332 
     | 
    
         
            +
                    @a = 'a'
         
     | 
| 
      
 333 
     | 
    
         
            +
                    r.is('a'){render('iv', :cache=>false)}
         
     | 
| 
      
 334 
     | 
    
         
            +
                    render('iv')
         
     | 
| 
      
 335 
     | 
    
         
            +
                  end
         
     | 
| 
      
 336 
     | 
    
         
            +
                end
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                body('/a').strip.must_equal "a"
         
     | 
| 
      
 339 
     | 
    
         
            +
                app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].must_equal nil
         
     | 
| 
      
 340 
     | 
    
         
            +
                body('/b').strip.must_equal "a"
         
     | 
| 
      
 341 
     | 
    
         
            +
                app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].wont_equal nil
         
     | 
| 
      
 342 
     | 
    
         
            +
              end
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
              it "Support :cache=>true option to enable template caching when :template_block is used" do
         
     | 
| 
      
 345 
     | 
    
         
            +
                c = Class.new do 
         
     | 
| 
      
 346 
     | 
    
         
            +
                  def initialize(path, *, &block)
         
     | 
| 
      
 347 
     | 
    
         
            +
                    @path = path
         
     | 
| 
      
 348 
     | 
    
         
            +
                    @block = block
         
     | 
| 
      
 349 
     | 
    
         
            +
                  end
         
     | 
| 
      
 350 
     | 
    
         
            +
                  def render(*)
         
     | 
| 
      
 351 
     | 
    
         
            +
                    "#{@path}-#{@block.call}"
         
     | 
| 
      
 352 
     | 
    
         
            +
                  end
         
     | 
| 
      
 353 
     | 
    
         
            +
                end 
         
     | 
| 
      
 354 
     | 
    
         
            +
             
     | 
| 
      
 355 
     | 
    
         
            +
                proca = proc{'a'}
         
     | 
| 
      
 356 
     | 
    
         
            +
             
     | 
| 
      
 357 
     | 
    
         
            +
                app(:bare) do
         
     | 
| 
      
 358 
     | 
    
         
            +
                  plugin :render, :views=>"./spec/views"
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
      
 360 
     | 
    
         
            +
                  route do |r|
         
     | 
| 
      
 361 
     | 
    
         
            +
                    @a = 'a'
         
     | 
| 
      
 362 
     | 
    
         
            +
                    r.is('a'){render(:path=>'iv', :template_class=>c, :template_block=>proca)}
         
     | 
| 
      
 363 
     | 
    
         
            +
                    render(:path=>'iv', :template_class=>c, :template_block=>proca, :cache=>true)
         
     | 
| 
      
 364 
     | 
    
         
            +
                  end
         
     | 
| 
      
 365 
     | 
    
         
            +
                end
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
      
 367 
     | 
    
         
            +
                body('/a').strip.must_equal "iv-a"
         
     | 
| 
      
 368 
     | 
    
         
            +
                app.render_opts[:cache][['iv', c, nil, nil, proca]].must_equal nil
         
     | 
| 
      
 369 
     | 
    
         
            +
                body('/b').strip.must_equal "iv-a"
         
     | 
| 
      
 370 
     | 
    
         
            +
                app.render_opts[:cache][['iv', c, nil, nil, proca]].wont_equal nil
         
     | 
| 
      
 371 
     | 
    
         
            +
              end
         
     | 
| 
      
 372 
     | 
    
         
            +
             
     | 
| 
      
 373 
     | 
    
         
            +
              it "Support :cache_key option to force the key used when caching" do
         
     | 
| 
      
 374 
     | 
    
         
            +
                app(:bare) do
         
     | 
| 
      
 375 
     | 
    
         
            +
                  plugin :render, :views=>"./spec/views"
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
                  route do |r|
         
     | 
| 
      
 378 
     | 
    
         
            +
                    @a = 'a'
         
     | 
| 
      
 379 
     | 
    
         
            +
                    r.is('a'){render('iv', :cache_key=>:a)}
         
     | 
| 
      
 380 
     | 
    
         
            +
                    r.is('about'){render('about', :cache_key=>:a, :cache=>false, :locals=>{:title=>'a'})}
         
     | 
| 
      
 381 
     | 
    
         
            +
                    render('about', :cache_key=>:a)
         
     | 
| 
       280 
382 
     | 
    
         
             
                  end
         
     | 
| 
       281 
383 
     | 
    
         
             
                end
         
     | 
| 
       282 
384 
     | 
    
         | 
| 
       283 
     | 
    
         
            -
                body('/a'). 
     | 
| 
       284 
     | 
    
         
            -
                body('/b'). 
     | 
| 
      
 385 
     | 
    
         
            +
                body('/a').strip.must_equal "a"
         
     | 
| 
      
 386 
     | 
    
         
            +
                body('/b').strip.must_equal "a"
         
     | 
| 
      
 387 
     | 
    
         
            +
                body('/about').strip.must_equal "<h1>a</h1>"
         
     | 
| 
       285 
388 
     | 
    
         
             
              end
         
     | 
| 
       286 
389 
     | 
    
         | 
| 
       287 
390 
     | 
    
         
             
              it "render_opts inheritance" do
         
     | 
| 
         @@ -289,15 +392,15 @@ describe "render plugin" do 
     | 
|
| 
       289 
392 
     | 
    
         
             
                c.plugin :render
         
     | 
| 
       290 
393 
     | 
    
         
             
                sc = Class.new(c)
         
     | 
| 
       291 
394 
     | 
    
         | 
| 
       292 
     | 
    
         
            -
                c.render_opts. 
     | 
| 
       293 
     | 
    
         
            -
                c.render_opts[:cache]. 
     | 
| 
      
 395 
     | 
    
         
            +
                c.render_opts.wont_be_same_as(sc.render_opts)
         
     | 
| 
      
 396 
     | 
    
         
            +
                c.render_opts[:cache].wont_be_same_as(sc.render_opts[:cache])
         
     | 
| 
       294 
397 
     | 
    
         
             
              end
         
     | 
| 
       295 
398 
     | 
    
         | 
| 
       296 
399 
     | 
    
         
             
              it "render plugin call should not override options" do
         
     | 
| 
       297 
400 
     | 
    
         
             
                c = Class.new(Roda)
         
     | 
| 
       298 
401 
     | 
    
         
             
                c.plugin :render, :layout=>:foo
         
     | 
| 
       299 
402 
     | 
    
         
             
                c.plugin :render
         
     | 
| 
       300 
     | 
    
         
            -
                c.render_opts[:layout]. 
     | 
| 
      
 403 
     | 
    
         
            +
                c.render_opts[:layout].must_equal :foo
         
     | 
| 
       301 
404 
     | 
    
         
             
              end
         
     | 
| 
       302 
405 
     | 
    
         | 
| 
       303 
406 
     | 
    
         
             
              it "with caching disabled" do
         
     | 
| 
         @@ -309,9 +412,9 @@ describe "render plugin" do 
     | 
|
| 
       309 
412 
     | 
    
         
             
                  end
         
     | 
| 
       310 
413 
     | 
    
         
             
                end
         
     | 
| 
       311 
414 
     | 
    
         | 
| 
       312 
     | 
    
         
            -
                body("/inline").strip. 
     | 
| 
      
 415 
     | 
    
         
            +
                body("/inline").strip.must_equal "Hello Agent Smith: false"
         
     | 
| 
       313 
416 
     | 
    
         | 
| 
       314 
     | 
    
         
            -
                Class.new(app).render_opts[:cache]. 
     | 
| 
      
 417 
     | 
    
         
            +
                Class.new(app).render_opts[:cache].must_equal false
         
     | 
| 
       315 
418 
     | 
    
         
             
              end
         
     | 
| 
       316 
419 
     | 
    
         
             
            end
         
     | 
| 
       317 
420 
     | 
    
         
             
            end
         
     | 
| 
         @@ -9,7 +9,7 @@ describe "shared_vars plugin" do 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  r.run old_app
         
     | 
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                body. 
     | 
| 
      
 12 
     | 
    
         
            +
                body.must_equal 'c'
         
     | 
| 
       13 
13 
     | 
    
         
             
              end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              it "adds shared with hash merges the hash into the shared vars" do
         
     | 
| 
         @@ -18,7 +18,7 @@ describe "shared_vars plugin" do 
     | 
|
| 
       18 
18 
     | 
    
         
             
                  shared[:c]
         
     | 
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                body. 
     | 
| 
      
 21 
     | 
    
         
            +
                body.must_equal 'c'
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              it "calling shared with hash and a block sets shared variables only for that block" do
         
     | 
| 
         @@ -33,13 +33,13 @@ describe "shared_vars plugin" do 
     | 
|
| 
       33 
33 
     | 
    
         
             
                  "#{shared[:c]}:#{shared[:d]}:#{c}:#{d}"
         
     | 
| 
       34 
34 
     | 
    
         
             
                end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                body. 
     | 
| 
      
 36 
     | 
    
         
            +
                body.must_equal 'b::c:d'
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
              it "calling shared with no arguments and a block raises an error" do
         
     | 
| 
       40 
40 
     | 
    
         
             
                app(:shared_vars) do |r|
         
     | 
| 
       41 
41 
     | 
    
         
             
                  shared{}
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
     | 
    
         
            -
                proc{body}. 
     | 
| 
      
 43 
     | 
    
         
            +
                proc{body}.must_raise(Roda::RodaError)
         
     | 
| 
       44 
44 
     | 
    
         
             
              end
         
     | 
| 
       45 
45 
     | 
    
         
             
            end
         
     |