deas 0.27.0 → 0.28.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.
Files changed (39) hide show
  1. data/lib/deas/logger.rb +10 -0
  2. data/lib/deas/redirect_proxy.rb +1 -1
  3. data/lib/deas/route.rb +10 -10
  4. data/lib/deas/route_proxy.rb +1 -1
  5. data/lib/deas/router.rb +1 -1
  6. data/lib/deas/runner.rb +12 -8
  7. data/lib/deas/server.rb +9 -2
  8. data/lib/deas/sinatra_app.rb +1 -0
  9. data/lib/deas/sinatra_runner.rb +15 -5
  10. data/lib/deas/template.rb +0 -4
  11. data/lib/deas/template_engine.rb +50 -0
  12. data/lib/deas/template_source.rb +74 -0
  13. data/lib/deas/test_runner.rb +7 -1
  14. data/lib/deas/version.rb +1 -1
  15. data/lib/deas/view_handler.rb +50 -44
  16. data/lib/deas.rb +1 -11
  17. data/test/support/fake_sinatra_call.rb +13 -10
  18. data/test/support/routes.rb +13 -21
  19. data/test/support/template.erb +1 -0
  20. data/test/support/template.json +1 -0
  21. data/test/support/test_template.test +0 -0
  22. data/test/support/view_handlers.rb +8 -0
  23. data/test/support/views/show.erb +1 -1
  24. data/test/system/rack_tests.rb +7 -5
  25. data/test/unit/error_handler_tests.rb +2 -1
  26. data/test/unit/logging_tests.rb +2 -1
  27. data/test/unit/route_tests.rb +16 -14
  28. data/test/unit/runner_tests.rb +7 -4
  29. data/test/unit/server_configuration_tests.rb +7 -4
  30. data/test/unit/server_tests.rb +6 -1
  31. data/test/unit/show_exceptions_tests.rb +2 -1
  32. data/test/unit/sinatra_app_tests.rb +16 -13
  33. data/test/unit/sinatra_runner_tests.rb +48 -0
  34. data/test/unit/template_engine_tests.rb +121 -0
  35. data/test/unit/template_source_tests.rb +221 -0
  36. data/test/unit/template_tests.rb +4 -12
  37. data/test/unit/test_runner_tests.rb +19 -7
  38. data/test/unit/view_handler_tests.rb +9 -2
  39. metadata +17 -4
@@ -1,7 +1,8 @@
1
1
  require 'assert'
2
- require 'test/support/fake_sinatra_call'
3
2
  require 'deas/logging'
4
3
 
4
+ require 'test/support/fake_sinatra_call'
5
+
5
6
  module Deas::Logging
6
7
 
7
8
  class UnitTests < Assert::Context
@@ -59,13 +59,14 @@ class Deas::Route
59
59
  assert_equal subject.handler_class, @runner_spy.handler_class
60
60
 
61
61
  exp_args = {
62
- :sinatra_call => @fake_sinatra_call,
63
- :request => @fake_sinatra_call.request,
64
- :response => @fake_sinatra_call.response,
65
- :params => @fake_sinatra_call.params,
66
- :logger => @fake_sinatra_call.settings.logger,
67
- :router => @fake_sinatra_call.settings.router,
68
- :session => @fake_sinatra_call.session
62
+ :sinatra_call => @fake_sinatra_call,
63
+ :request => @fake_sinatra_call.request,
64
+ :response => @fake_sinatra_call.response,
65
+ :session => @fake_sinatra_call.session,
66
+ :params => @fake_sinatra_call.params,
67
+ :logger => @fake_sinatra_call.settings.logger,
68
+ :router => @fake_sinatra_call.settings.router,
69
+ :template_source => @fake_sinatra_call.settings.template_source
69
70
  }
70
71
  assert_equal exp_args, @runner_spy.args
71
72
 
@@ -107,13 +108,14 @@ class Deas::Route
107
108
  def build(handler_class, args)
108
109
  @handler_class, @args = handler_class, args
109
110
 
110
- @sinatra_call = args[:sinatra_call]
111
- @request = args[:request]
112
- @response = args[:response]
113
- @params = args[:params]
114
- @logger = args[:logger]
115
- @router = args[:router]
116
- @session = args[:session]
111
+ @sinatra_call = args[:sinatra_call]
112
+ @request = args[:request]
113
+ @response = args[:response]
114
+ @session = args[:session]
115
+ @params = args[:params]
116
+ @logger = args[:logger]
117
+ @router = args[:router]
118
+ @template_source = args[:template_source]
117
119
  end
118
120
 
119
121
  def run
@@ -1,6 +1,7 @@
1
1
  require 'assert'
2
2
  require 'deas/runner'
3
3
 
4
+ require 'deas/logger'
4
5
  require 'deas/router'
5
6
  require 'test/support/view_handlers'
6
7
 
@@ -23,10 +24,10 @@ class Deas::Runner
23
24
  subject{ @runner }
24
25
 
25
26
  should have_readers :handler_class, :handler
26
- should have_readers :request, :response, :params
27
- should have_readers :logger, :router, :session
27
+ should have_readers :request, :response, :session
28
+ should have_readers :params, :logger, :router, :template_source
28
29
  should have_imeths :halt, :redirect, :content_type, :status, :headers
29
- should have_imeths :render, :send_file
30
+ should have_imeths :render, :partial, :send_file
30
31
 
31
32
  should "know its handler and handler class" do
32
33
  assert_equal EmptyViewHandler, subject.handler_class
@@ -36,10 +37,11 @@ class Deas::Runner
36
37
  should "default its settings" do
37
38
  assert_nil subject.request
38
39
  assert_nil subject.response
40
+ assert_nil subject.session
39
41
  assert_kind_of ::Hash, subject.params
40
42
  assert_kind_of Deas::NullLogger, subject.logger
41
43
  assert_kind_of Deas::Router, subject.router
42
- assert_nil subject.session
44
+ assert_kind_of Deas::NullTemplateSource, subject.template_source
43
45
  end
44
46
 
45
47
  should "default its params" do
@@ -54,6 +56,7 @@ class Deas::Runner
54
56
  assert_raises(NotImplementedError){ subject.status }
55
57
  assert_raises(NotImplementedError){ subject.headers }
56
58
  assert_raises(NotImplementedError){ subject.render }
59
+ assert_raises(NotImplementedError){ subject.partial }
57
60
  assert_raises(NotImplementedError){ subject.send_file }
58
61
  end
59
62
 
@@ -1,10 +1,12 @@
1
1
  require 'assert'
2
2
  require 'deas/server'
3
3
 
4
- require 'test/support/view_handlers'
5
4
  require 'deas/exceptions'
6
- require 'deas/template'
5
+ require 'deas/logger'
7
6
  require 'deas/router'
7
+ require 'deas/template'
8
+ require 'deas/template_source'
9
+ require 'test/support/view_handlers'
8
10
 
9
11
  class Deas::Server::Configuration
10
12
 
@@ -24,7 +26,7 @@ class Deas::Server::Configuration
24
26
 
25
27
  # server handling options
26
28
 
27
- should have_imeths :verbose_logging, :logger
29
+ should have_imeths :verbose_logging, :logger, :template_source
28
30
 
29
31
  should have_accessors :settings, :error_procs, :init_procs, :template_helpers
30
32
  should have_accessors :middlewares, :router
@@ -49,8 +51,9 @@ class Deas::Server::Configuration
49
51
  end
50
52
 
51
53
  should "default the handling options" do
52
- assert_instance_of Deas::NullLogger, subject.logger
53
54
  assert_equal true, subject.verbose_logging
55
+ assert_instance_of Deas::NullLogger, subject.logger
56
+ assert_instance_of Deas::NullTemplateSource, subject.template_source
54
57
  end
55
58
 
56
59
  should "default its stored configuration" do
@@ -3,6 +3,7 @@ require 'deas/server'
3
3
 
4
4
  require 'logger'
5
5
  require 'deas/router'
6
+ require 'deas/template_source'
6
7
 
7
8
  module Deas::Server
8
9
 
@@ -22,7 +23,7 @@ module Deas::Server
22
23
 
23
24
  # DSL for server handling settings
24
25
  should have_imeths :init, :error, :template_helpers, :template_helper?
25
- should have_imeths :use, :set, :verbose_logging, :logger
26
+ should have_imeths :use, :set, :verbose_logging, :logger, :template_source
26
27
  should have_imeths :get, :post, :put, :patch, :delete
27
28
  should have_imeths :redirect, :route, :url, :url_for
28
29
 
@@ -87,6 +88,10 @@ module Deas::Server
87
88
  subject.logger stdout_logger
88
89
  assert_equal stdout_logger, config.logger
89
90
 
91
+ a_source = Deas::TemplateSource.new(Factory.path)
92
+ subject.template_source a_source
93
+ assert_equal a_source, config.template_source
94
+
90
95
  subject.default_charset 'latin1'
91
96
  assert_equal 'latin1', config.default_charset
92
97
  end
@@ -1,7 +1,8 @@
1
1
  require 'assert'
2
- require 'rack/utils'
3
2
  require 'deas/show_exceptions'
4
3
 
4
+ require 'rack/utils'
5
+
5
6
  class Deas::ShowExceptions
6
7
 
7
8
  class UnitTests < Assert::Context
@@ -1,11 +1,13 @@
1
1
  require 'assert'
2
+ require 'deas/sinatra_app'
3
+
2
4
  require 'sinatra/base'
3
- require 'test/support/view_handlers'
5
+ require 'deas/logger'
4
6
  require 'deas/route_proxy'
5
7
  require 'deas/route'
6
8
  require 'deas/router'
7
9
  require 'deas/server'
8
- require 'deas/sinatra_app'
10
+ require 'test/support/view_handlers'
9
11
 
10
12
  module Deas::SinatraApp
11
13
 
@@ -42,17 +44,18 @@ module Deas::SinatraApp
42
44
 
43
45
  should "have it's configuration set based on the server configuration" do
44
46
  subject.settings.tap do |settings|
45
- assert_equal 'staging', settings.environment
46
- assert_equal 'path/to/somewhere', settings.root.to_s
47
- assert_equal 'path/to/somewhere/public', settings.public_folder.to_s
48
- assert_equal 'path/to/somewhere/views', settings.views.to_s
49
- assert_equal true, settings.dump_errors
50
- assert_equal false, settings.method_override
51
- assert_equal false, settings.sessions
52
- assert_equal true, settings.static
53
- assert_equal true, settings.reload_templates
54
- assert_instance_of Deas::NullLogger, settings.logger
55
- assert_instance_of Deas::Router, settings.router
47
+ assert_equal 'staging', settings.environment
48
+ assert_equal 'path/to/somewhere', settings.root.to_s
49
+ assert_equal 'path/to/somewhere/public', settings.public_folder.to_s
50
+ assert_equal 'path/to/somewhere/views', settings.views.to_s
51
+ assert_equal true, settings.dump_errors
52
+ assert_equal false, settings.method_override
53
+ assert_equal false, settings.sessions
54
+ assert_equal true, settings.static
55
+ assert_equal true, settings.reload_templates
56
+ assert_instance_of Deas::NullLogger, settings.logger
57
+ assert_instance_of Deas::Router, settings.router
58
+ assert_instance_of Deas::NullTemplateSource, settings.template_source
56
59
 
57
60
  # settings that are set but can't be changed
58
61
  assert_equal false, settings.logging
@@ -94,6 +94,14 @@ class Deas::SinatraRunner
94
94
  })
95
95
  end
96
96
 
97
+ should "render partials with locals" do
98
+ exp_result = Deas::Template::Partial.new(@fake_sinatra_call, 'info', {
99
+ :some => 'locals'
100
+ }).render
101
+
102
+ assert_equal exp_result, subject.partial('info', :some => 'locals')
103
+ end
104
+
97
105
  should "call the sinatra_call's send_file to set the send files" do
98
106
  block_called = false
99
107
  args = subject.send_file('a/file', {:some => 'opts'}, &proc{ block_called = true })
@@ -104,4 +112,44 @@ class Deas::SinatraRunner
104
112
 
105
113
  end
106
114
 
115
+ class InitWithEngineTests < UnitTests
116
+ desc "when init with a template source and matching engine"
117
+ setup do
118
+ @fake_sinatra_call = FakeSinatraCall.new
119
+ @runner = @runner_class.new(DeasRunnerViewHandler, {
120
+ :sinatra_call => @fake_sinatra_call,
121
+ :template_source => FakeTemplateSource.new
122
+ })
123
+ end
124
+ subject{ @runner }
125
+
126
+ should "render templates using the source" do
127
+ exp_handler = DeasRunnerViewHandler.new(subject)
128
+ exp_locals = {
129
+ :view => exp_handler,
130
+ :logger => @runner.logger,
131
+ :some => 'locals'
132
+ }
133
+ exp = ['render', 'info', @runner.handler, exp_locals]
134
+ assert_equal exp, subject.render('info', :locals => {
135
+ :some => 'locals'
136
+ })
137
+ end
138
+
139
+ should "render partials using the source" do
140
+ exp = ['partial', 'info', { :some => 'locals' }]
141
+ assert_equal exp, subject.partial('info', { :some => 'locals' })
142
+ end
143
+
144
+ end
145
+
146
+ class FakeTemplateSource
147
+ def engine_for?(template_name)
148
+ true
149
+ end
150
+
151
+ def render(*args); ['render', *args]; end
152
+ def partial(*args); ['partial', *args]; end
153
+ end
154
+
107
155
  end
@@ -0,0 +1,121 @@
1
+ require 'assert'
2
+ require 'deas/template_engine'
3
+
4
+ require 'pathname'
5
+ require 'deas/logger'
6
+ require 'test/support/factory'
7
+
8
+ class Deas::TemplateEngine
9
+
10
+ class UnitTests < Assert::Context
11
+ desc "Deas::TemplateEngine"
12
+ setup do
13
+ @source_path = Factory.path
14
+ @template_name = Factory.path
15
+ @view_handler = 'a-view-handler'
16
+ @locals = {}
17
+ @content = Proc.new{}
18
+ @engine = Deas::TemplateEngine.new('some' => 'opts')
19
+ end
20
+ subject{ @engine }
21
+
22
+ should have_readers :source_path, :logger, :opts
23
+ should have_imeths :render, :partial, :capture_partial
24
+
25
+ should "default its source path" do
26
+ assert_equal Pathname.new(nil.to_s), subject.source_path
27
+ end
28
+
29
+ should "allow custom source paths" do
30
+ engine = Deas::TemplateEngine.new('source_path' => @source_path)
31
+ assert_equal Pathname.new(@source_path.to_s), engine.source_path
32
+ end
33
+
34
+ should "default its logger" do
35
+ assert_instance_of Deas::NullLogger, subject.logger
36
+ end
37
+
38
+ should "allow custom source loggers" do
39
+ logger = 'a-logger'
40
+ engine = Deas::TemplateEngine.new('logger' => logger)
41
+ assert_equal logger, engine.logger
42
+ end
43
+
44
+ should "default the opts if none given" do
45
+ exp_opts = {}
46
+ assert_equal exp_opts, Deas::TemplateEngine.new.opts
47
+ end
48
+
49
+ should "allow custom opts" do
50
+ exp_opts = {'some' => 'opts'}
51
+ assert_equal exp_opts, subject.opts
52
+ end
53
+
54
+ should "raise NotImplementedError on `render`" do
55
+ assert_raises NotImplementedError do
56
+ subject.render(@template_name, @view_handler, @locals)
57
+ end
58
+ end
59
+
60
+ should "raise NotImplementedError on `partial`" do
61
+ assert_raises NotImplementedError do
62
+ subject.partial(@template_name, @locals)
63
+ end
64
+ end
65
+
66
+ should "raise NotImplementedError on `capture_partial`" do
67
+ assert_raises NotImplementedError do
68
+ subject.capture_partial(@template_name, @locals, &@content)
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ class NullTemplateEngineTests < Assert::Context
75
+ desc "Deas::NullTemplateEngine"
76
+ setup do
77
+ @v = 'a-view-handler'
78
+ @l = {}
79
+ @c = Proc.new{}
80
+ @engine = Deas::NullTemplateEngine.new('source_path' => ROOT.to_s)
81
+ end
82
+ subject{ @engine }
83
+
84
+ should "be a TemplateEngine" do
85
+ assert_kind_of Deas::TemplateEngine, subject
86
+ end
87
+
88
+ should "read and return the given path in its source path on `render`" do
89
+ exists_file = 'test/support/template.json'
90
+ exp = File.read(subject.source_path.join(exists_file).to_s)
91
+ assert_equal exp, subject.render(exists_file, @v, @l)
92
+ end
93
+
94
+ should "call `render` to implement its `partial` method" do
95
+ exists_file = 'test/support/template.json'
96
+ exp = subject.render(exists_file, nil, @l)
97
+ assert_equal exp, subject.partial(exists_file, @l)
98
+ end
99
+
100
+ should "call `render` to implement its `capture_partial` method" do
101
+ exists_file = 'test/support/template.json'
102
+ exp = subject.render(exists_file, nil, @l)
103
+ assert_equal exp, subject.capture_partial(exists_file, @l, &@c)
104
+ end
105
+
106
+ should "complain if given a path that does not exist in its source path" do
107
+ no_exists_file = '/does/not/exists'
108
+ assert_raises ArgumentError do
109
+ subject.render(no_exists_file, @v, @l)
110
+ end
111
+ assert_raises ArgumentError do
112
+ subject.partial(no_exists_file, @l)
113
+ end
114
+ assert_raises ArgumentError do
115
+ subject.capture_partial(no_exists_file, @l, &@c)
116
+ end
117
+ end
118
+
119
+ end
120
+
121
+ end
@@ -0,0 +1,221 @@
1
+ require 'assert'
2
+ require 'deas/template_source'
3
+
4
+ require 'deas/template_engine'
5
+
6
+ class Deas::TemplateSource
7
+
8
+ class UnitTests < Assert::Context
9
+ desc "Deas::TemplateSource"
10
+ subject{ Deas::TemplateSource }
11
+
12
+ should "disallow certain engine extensions" do
13
+ exp = [ 'rb' ]
14
+ assert_equal exp, subject::DISALLOWED_ENGINE_EXTS
15
+ end
16
+
17
+ end
18
+
19
+ class InitTests < Assert::Context
20
+ setup do
21
+ @source_path = ROOT.join('test/support').to_s
22
+ @logger = 'a-logger'
23
+ @source = Deas::TemplateSource.new(@source_path, @logger)
24
+ end
25
+ subject{ @source }
26
+
27
+ should have_readers :path, :engines
28
+ should have_imeths :engine, :engine_for?
29
+ should have_imeths :render, :partial, :capture_partial
30
+
31
+ should "know its path" do
32
+ assert_equal @source_path.to_s, subject.path
33
+ end
34
+
35
+ end
36
+
37
+ class EngineRegistrationTests < InitTests
38
+ desc "when registering an engine"
39
+ setup do
40
+ @test_engine = TestEngine
41
+ end
42
+
43
+ should "allow registering new engines" do
44
+ assert_kind_of Deas::NullTemplateEngine, subject.engines['test']
45
+ subject.engine 'test', @test_engine
46
+ assert_kind_of @test_engine, subject.engines['test']
47
+ end
48
+
49
+ should "register with default options" do
50
+ subject.engine 'test', @test_engine
51
+ exp_opts = {
52
+ 'source_path' => subject.path,
53
+ 'logger' => @logger
54
+ }
55
+ assert_equal exp_opts, subject.engines['test'].opts
56
+
57
+ subject.engine 'test', @test_engine, 'an' => 'opt'
58
+ exp_opts = {
59
+ 'source_path' => subject.path,
60
+ 'logger' => @logger,
61
+ 'an' => 'opt'
62
+ }
63
+ assert_equal exp_opts, subject.engines['test'].opts
64
+
65
+ subject.engine('test', @test_engine, {
66
+ 'source_path' => 'something',
67
+ 'logger' => 'another'
68
+ })
69
+ exp_opts = {
70
+ 'source_path' => 'something',
71
+ 'logger' => 'another'
72
+ }
73
+ assert_equal exp_opts, subject.engines['test'].opts
74
+
75
+ source = Deas::TemplateSource.new(@source_path)
76
+ source.engine('test', @test_engine)
77
+ assert_instance_of Deas::NullLogger, source.engines['test'].opts['logger']
78
+ end
79
+
80
+ should "complain if registering a disallowed temp" do
81
+ assert_kind_of Deas::NullTemplateEngine, subject.engines['rb']
82
+ assert_raises DisallowedEngineExtError do
83
+ subject.engine 'rb', @test_engine
84
+ end
85
+ assert_kind_of Deas::NullTemplateEngine, subject.engines['rb']
86
+ end
87
+
88
+ should "know if it has an engine registered for a given template name" do
89
+ assert_false subject.engine_for?('test_template')
90
+
91
+ subject.engine 'test', @test_engine
92
+ assert_true subject.engine_for?('test_template')
93
+ end
94
+
95
+ end
96
+
97
+ class RenderOrPartialTests < InitTests
98
+ setup do
99
+ @source.engine('test', TestEngine)
100
+ @source.engine('json', JsonEngine)
101
+
102
+ @v = TestServiceHandler
103
+ @l = {}
104
+ @c = Proc.new{}
105
+ end
106
+
107
+ end
108
+
109
+ class RenderTests < RenderOrPartialTests
110
+ desc "when rendering a template"
111
+
112
+ should "call `render` on the configured engine" do
113
+ result = subject.render('test_template', @v, @l)
114
+ assert_equal 'render-test-engine', result
115
+ end
116
+
117
+ should "only try rendering template files its has engines for" do
118
+ # there should be 2 files called "template" in `test/support` with diff
119
+ # extensions
120
+ result = subject.render('template', @v, @l)
121
+ assert_equal 'render-json-engine', result
122
+ end
123
+
124
+ should "use the null template engine when an engine can't be found" do
125
+ assert_raises(ArgumentError) do
126
+ subject.render(Factory.string, @v, @l)
127
+ end
128
+ end
129
+
130
+ end
131
+
132
+ class PartialTests < RenderTests
133
+ desc "when partial rendering a template"
134
+
135
+ should "call `partial` on the configured engine" do
136
+ result = subject.partial('test_template', @l)
137
+ assert_equal 'partial-test-engine', result
138
+ end
139
+
140
+ should "only try rendering template files its has engines for" do
141
+ # there should be 2 files called "template" in `test/support` with diff
142
+ # extensions
143
+ result = subject.partial('template', @l)
144
+ assert_equal 'partial-json-engine', result
145
+ end
146
+
147
+ should "use the null template engine when an engine can't be found" do
148
+ assert_raises(ArgumentError) do
149
+ subject.partial(Factory.string, @l)
150
+ end
151
+ end
152
+
153
+ end
154
+
155
+ class CapturePartialTests < RenderOrPartialTests
156
+ desc "when capture partial rendering a template"
157
+
158
+ should "call `capture_partial` on the configured engine" do
159
+ result = subject.capture_partial('test_template', @l, &@c)
160
+ assert_equal 'capture-partial-test-engine', result
161
+ end
162
+
163
+ should "only try rendering template files its has engines for" do
164
+ # there should be 2 files called "template" in `test/support` with diff
165
+ # extensions
166
+ result = subject.capture_partial('template', @l, &@c)
167
+ assert_equal 'capture-partial-json-engine', result
168
+ end
169
+
170
+ should "use the null template engine when an engine can't be found" do
171
+ assert_raises(ArgumentError) do
172
+ subject.capture_partial(Factory.string, @l, &@c)
173
+ end
174
+ end
175
+
176
+ end
177
+
178
+ class NullTemplateSourceTests < Assert::Context
179
+ desc "Deas::NullTemplateSource"
180
+ setup do
181
+ @source = Deas::NullTemplateSource.new
182
+ end
183
+ subject{ @source }
184
+
185
+ should "be a template source" do
186
+ assert_kind_of Deas::TemplateSource, subject
187
+ end
188
+
189
+ should "have an empty path string" do
190
+ assert_equal '', subject.path
191
+ end
192
+
193
+ end
194
+
195
+ class TestEngine < Deas::TemplateEngine
196
+ def render(template_name, view_handler, locals)
197
+ 'render-test-engine'
198
+ end
199
+ def partial(template_name, locals)
200
+ 'partial-test-engine'
201
+ end
202
+ def capture_partial(template_name, locals, &content)
203
+ 'capture-partial-test-engine'
204
+ end
205
+ end
206
+
207
+ class JsonEngine < Deas::TemplateEngine
208
+ def render(template_name, view_handler, locals)
209
+ 'render-json-engine'
210
+ end
211
+ def partial(template_name, locals)
212
+ 'partial-json-engine'
213
+ end
214
+ def capture_partial(template_name, locals, &content)
215
+ 'capture-partial-json-engine'
216
+ end
217
+ end
218
+
219
+ TestServiceHandler = Class.new
220
+
221
+ end
@@ -1,7 +1,8 @@
1
1
  require 'assert'
2
- require 'test/support/fake_sinatra_call'
3
2
  require 'deas/template'
4
3
 
4
+ require 'test/support/fake_sinatra_call'
5
+
5
6
  class Deas::Template
6
7
 
7
8
  class UnitTests < Assert::Context
@@ -100,7 +101,7 @@ class Deas::Template
100
101
  end
101
102
 
102
103
  should "call the sinatra_call's erb method with #partial" do
103
- render_args = subject.partial('part', {
104
+ render_args = subject.partial('_part', {
104
105
  :something => true
105
106
  }, &Proc.new{ '#partial called this proc' })
106
107
 
@@ -130,7 +131,7 @@ class Deas::Template
130
131
  class PartialTests < UnitTests
131
132
  desc "Partial"
132
133
  setup do
133
- @partial = Deas::Template::Partial.new(@fake_sinatra_call, 'users/index/listing', {
134
+ @partial = Deas::Template::Partial.new(@fake_sinatra_call, 'users/index/_listing', {
134
135
  :user => 'Joe Test'
135
136
  })
136
137
  end
@@ -140,15 +141,6 @@ class Deas::Template
140
141
  assert_kind_of Deas::Template, subject
141
142
  end
142
143
 
143
- should "add an underscore to it's template's basename" do
144
- assert_equal :"users/index/_listing", subject.name
145
- end
146
-
147
- should "not add an underscore to it's template's basename if one already exists" do
148
- partial = Deas::Template::Partial.new(@fake_sinatra_call, 'users/index/_listing')
149
- assert_equal :"users/index/_listing", partial.name
150
- end
151
-
152
144
  should "set it's locals option" do
153
145
  assert_equal({ :user => 'Joe Test' }, subject.options[:locals])
154
146
  end