pakada-dispatch 0.2.3 → 0.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.
@@ -4,6 +4,7 @@ require "pakada"
4
4
 
5
5
  require "pakada/dispatch/controller"
6
6
  require "pakada/dispatch/module"
7
+ require "pakada/dispatch/rendering_context"
7
8
  require "pakada/dispatch/version"
8
9
 
9
10
  class Pakada::Dispatch
@@ -13,12 +14,6 @@ class Pakada::Dispatch
13
14
 
14
15
  def initialize
15
16
  @router = HttpRouter.new
16
- Pakada.safety(Controller).extend Hooked
17
- Pakada.safety(Controller).around(:included) {|inner, klass|
18
- klass.send :include, Hooked
19
- klass.extend Hooked
20
- inner.call klass
21
- }
22
17
  end
23
18
 
24
19
  def hooks
@@ -27,10 +22,24 @@ class Pakada::Dispatch
27
22
 
28
23
  def boot
29
24
  Pakada.modules.each_value {|mod|
30
- mod.extend Pakada.safety(::Pakada::Dispatch::Module)
25
+ mod.extend Pakada.safety(Pakada::Dispatch::Module)
31
26
  mod.load_controllers
32
27
  mod.routes if mod.respond_to? :routes
33
28
  }
29
+
30
+ if Pakada[:render]
31
+ context = Pakada.safety(Pakada::Render::RenderingContext)
32
+ extension = Pakada.safety(Pakada::Dispatch::RenderingContext)
33
+ context.send :include, extension
34
+ end
35
+ end
36
+
37
+ def create_controller(&block)
38
+ Class.new {
39
+ include Pakada.safety(Pakada::Dispatch::Controller)
40
+ include Hooked
41
+ class_eval &block if block
42
+ }
34
43
  end
35
44
 
36
45
  def request(env)
@@ -8,37 +8,57 @@ class Pakada
8
8
  klass.extend Pakada.safety(self::ClassMethods)
9
9
  end
10
10
 
11
- def self.create(&block)
12
- Class.new.tap {|cls|
13
- cls.send :include, self
14
- cls.class_eval &block
15
- }
16
- end
17
-
18
11
  attr_reader :options, :params, :request, :response
19
12
 
20
- def initialize(env, options = {}, &block)
13
+ def initialize(env, options = {})
21
14
  @request = Rack::Request.new(env)
22
15
  @response = options[:response] || Rack::Response.new
23
-
24
- @options, @params = options, request.env["router.params"]
25
- (request.env["pakada.controllers"] ||= []) << self
26
-
27
- catch(:finish) { instance_eval &block }
16
+ @options, @params = options, request.env["router.params"].dup
17
+ end
18
+
19
+ def process(&block)
20
+ instance_eval &block
21
+ self
28
22
  end
29
23
 
30
24
  def finish!
31
25
  throw :finish
32
26
  end
33
27
 
34
- def actions
35
- self.class.actions
28
+ def not_found
29
+ response.status = 404
30
+ end
31
+
32
+ def not_found!
33
+ not_found
34
+ finish!
35
+ end
36
+
37
+ def access_denied
38
+ response.status = 403
39
+ end
40
+
41
+ def access_denied!
42
+ access_denied
43
+ finish!
44
+ end
45
+
46
+ def json(data)
47
+ options[:render] = false
48
+ options[:layout] = false
49
+ response.headers["Content-Type"] = "application/json"
50
+ response.write data.to_json
51
+ end
52
+
53
+ def json!(data)
54
+ json data
55
+ finish!
36
56
  end
37
57
 
38
58
  def action(name, options = {})
39
- aecktschn = self.class.action(name)
40
59
  options[:response] ||= response
41
- proc { aecktschn.call request.env, options }
60
+ aecktschn = self.class.action(name, options)
61
+ proc { aecktschn.call request.env }
42
62
  end
43
63
 
44
64
  module ClassMethods
@@ -48,24 +68,39 @@ class Pakada
48
68
 
49
69
  def action(name, options = {}, &block)
50
70
  if block
51
- actions[name] = proc {|env, *args|
52
- opts = (args[0] || {}).merge(:action => name)
53
- action = self.new(env, options.merge(opts), &block)
54
- action.response.finish unless opts[:response]
71
+ actions[name] = {
72
+ :block => block,
73
+ :options => options
74
+ }
75
+ else
76
+ unless action = actions[name]
77
+ raise ArgumentError, "Unknown action: #{name}"
78
+ end
79
+
80
+ options = self.options.dup.tap {|opts|
81
+ opts.merge! action[:options]
82
+ opts.merge! options
83
+ opts.merge! :action => name
84
+ }
85
+
86
+ proc {|env|
87
+ self.new(env, options).process(&action[:block]).response.finish
55
88
  }
56
89
  end
57
- actions[name]
90
+ end
91
+
92
+ def options(opts = {})
93
+ (@options ||= {}).tap {|o| o.merge! opts }
58
94
  end
59
95
 
60
96
  def to_proc
61
97
  method(:call).to_proc
62
98
  end
63
99
 
64
- def call(env, options = {})
100
+ def call(env)
65
101
  env["router.params"] ||= {}
66
- name = env["router.params"][:action] ||
67
- env["REQUEST_METHOD"].downcase
68
- action(name.to_sym).call env, options
102
+ name = env["router.params"][:action] || env["REQUEST_METHOD"].downcase
103
+ action(name.to_sym).call env
69
104
  end
70
105
  end
71
106
  end
@@ -13,11 +13,9 @@ class Pakada
13
13
 
14
14
  def controller(name, &block)
15
15
  if block
16
- controllers[name] = Pakada.safety(Controller).create(&block).tap {|c|
17
- c.before(:new) {|env, *args|
18
- options = args[0] || {}
19
- options.merge! :module => pakada_name, :controller => name
20
- }
16
+ controllers[name] = Pakada[:dispatch].create_controller(&block).tap {|c|
17
+ c.options[:controller] = name
18
+ c.options[:module] = pakada_name
21
19
  }
22
20
  else
23
21
  controllers[name]
@@ -0,0 +1,7 @@
1
+ class Pakada::Dispatch
2
+ module RenderingContext
3
+ def url(route, params = {})
4
+ Pakada[:dispatch].router.url route, params
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  class Pakada
2
2
  class Dispatch
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "rspec"
20
20
  s.add_development_dependency "yard"
21
21
  s.add_development_dependency "rdiscount"
22
+ s.add_development_dependency "pakada-render"
22
23
 
23
24
  s.files = `git ls-files`.split("\n") - [".gitignore", "config.ru"]
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -3,10 +3,11 @@ require "spec_helper"
3
3
  describe Pakada::Dispatch::Controller do
4
4
  let(:block) { proc {} }
5
5
  let(:ctrlr_mod) { Pakada.safety Pakada::Dispatch::Controller }
6
- let(:ctrlr) { ctrlr_mod.create &block }
6
+ let(:ctrlr) { Pakada[:dispatch].create_controller &block }
7
7
  let(:ctrlr_obj) { ctrlr.new env, options, &block }
8
- let(:env) { {"router.params" => stub("router params")} }
9
- let(:options) { {:response => stub("response")} }
8
+ let(:env) { {"router.params" => {}} }
9
+ let(:options) { {} }
10
+ let(:response) { ctrlr_obj.response }
10
11
 
11
12
  context ".included hook" do
12
13
  it "extends the includer class with ClassMethods" do
@@ -15,23 +16,13 @@ describe Pakada::Dispatch::Controller do
15
16
  end
16
17
  end
17
18
 
18
- context ".create(name) { ... }" do
19
- let(:klass) { stub "class" }
20
-
21
- before { Class.stub :new => klass }
22
-
23
- it "includes itself into a new class and calls the block in its context" do
24
- klass.should_receive(:include).with ctrlr_mod
25
- klass.should_receive(:class_eval) {|&blk| block.should equal(blk) }
26
-
27
- ctrlr
28
- end
29
- end
30
-
31
19
  context "#initialize(env, options) { ... }" do
20
+ let(:options) { {:response => stub("response")} }
21
+
32
22
  it "sets the options and routing params objects" do
33
23
  ctrlr_obj.options.should equal(options)
34
- ctrlr_obj.params.should equal(env["router.params"])
24
+ ctrlr_obj.params.should == env["router.params"]
25
+ ctrlr_obj.params.should_not equal(env["router.params"])
35
26
  end
36
27
 
37
28
  it "sets the request and response objects" do
@@ -45,56 +36,99 @@ describe Pakada::Dispatch::Controller do
45
36
  ctrlr_obj.response.status.should equal(200)
46
37
  ctrlr_obj.response.should_not equal(old_response)
47
38
  end
48
-
49
- it "adds itself to env[pakada.controllers]" do
50
- ctrlr_obj
51
- env["pakada.controllers"].should == [ctrlr_obj]
39
+ end
40
+
41
+ context "#finish!" do
42
+ it "throws :finish" do
43
+ proc { ctrlr_obj.finish! }.should throw_symbol(:finish)
52
44
  end
45
+ end
46
+
47
+ context "#process { ... }" do
48
+ let(:block) { proc {} }
53
49
 
54
- let(:ctrlr_alloc) { ctrlr.allocate }
55
-
56
- it "instance_evals the passed block, catching :finish" do
57
- ctrlr_alloc.should_receive(:instance_eval) {|&blk|
58
- blk.should equal(block)
59
- throw :catch
50
+ it "instance_evals the passed block" do
51
+ ctrlr_obj.should_receive(:instance_eval) {|&blk|
52
+ block.should equal(blk)
60
53
  }
61
- proc {
62
- ctrlr_alloc.send :initialize, env, &block
63
- }.should throw_symbol(:catch)
54
+ ctrlr_obj.process &block
55
+ end
56
+
57
+ it "returns the controller object" do
58
+ ctrlr_obj.process(&block).should equal(ctrlr_obj)
64
59
  end
65
60
  end
66
61
 
67
- context "#finish!" do
68
- it "throws :finish" do
69
- proc { ctrlr_obj.finish! }.should throw_symbol(:finish)
62
+ context "#not_found" do
63
+ it "sets a 404 status" do
64
+ ctrlr_obj.not_found
65
+ response.status.should equal(404)
66
+ end
67
+ end
68
+
69
+ context "#not_found!" do
70
+ it "sets a 404 status and finishes" do
71
+ ctrlr_obj.should_receive :not_found
72
+ ctrlr_obj.should_receive :finish!
73
+ ctrlr_obj.not_found!
74
+ end
75
+ end
76
+
77
+ context "#access_denied" do
78
+ it "sets a 403 status" do
79
+ ctrlr_obj.access_denied
80
+ response.status.should equal(403)
81
+ end
82
+ end
83
+
84
+ context "#access_denied!" do
85
+ it "sets a 403 status and finishes" do
86
+ ctrlr_obj.should_receive :access_denied
87
+ ctrlr_obj.should_receive :finish!
88
+ ctrlr_obj.access_denied!
89
+ end
90
+ end
91
+
92
+ context "#json" do
93
+ let(:data) { stub "data", :to_json => stub("json_data") }
94
+
95
+ it "sets a JSON response" do
96
+ response.should_receive(:write).with data.to_json
97
+ ctrlr_obj.json data
98
+ response.headers["Content-Type"].should == "application/json"
70
99
  end
71
100
  end
72
101
 
73
- context "#actions" do
74
- let(:actions) { stub "action" }
102
+ context "#json!" do
103
+ let(:data) { stub "data" }
75
104
 
76
- it "forwards to .actions" do
77
- ctrlr.should_receive(:actions) { actions }
78
- ctrlr_obj.actions.should equal(actions)
105
+ it "sets a JSON response and finishes" do
106
+ ctrlr_obj.should_receive(:json).with data
107
+ ctrlr_obj.should_receive :finish!
108
+ ctrlr_obj.json! data
79
109
  end
80
110
  end
81
111
 
82
112
  context "#action(name, options = {})" do
113
+ let(:actions) { {:foo => stub("foo action")} }
114
+
83
115
  before {
84
- ctrlr_obj.actions[:foo] = stub("action")
116
+ ctrlr.stub(:action) {|name, *| actions[name] }
85
117
  }
86
118
 
87
119
  it "forwards to .action" do
88
- ctrlr.action(:foo).should_receive(:call) {|env, opts|
120
+ actions[:foo].should_receive(:call) {|env|
89
121
  env.should equal(ctrlr_obj.request.env)
90
122
  }
91
123
  ctrlr_obj.action(:foo).call
92
124
  end
93
125
 
94
126
  it "passes the response in options" do
95
- ctrlr.action(:foo).should_receive(:call) {|env, opts|
96
- opts.should == options
127
+ ctrlr.should_receive(:action) {|name, opts|
128
+ opts[:response].should equal(ctrlr_obj.response)
129
+ actions[:foo]
97
130
  }
131
+ actions[:foo].should_receive(:call)
98
132
  ctrlr_obj.action(:foo).call
99
133
  end
100
134
  end
@@ -106,54 +140,104 @@ describe Pakada::Dispatch::Controller do
106
140
  end
107
141
  end
108
142
 
109
- context ".action(name)" do
110
- let(:action) { stub "action" }
111
- before { ctrlr.actions[:foo] = action }
143
+ context ".action(name, options = {}) { ... }" do
144
+ let(:block) { proc {} }
145
+ let(:options) { {:key => :value} }
112
146
 
113
- it "returns the specified action" do
114
- ctrlr.action(:foo).should equal(action)
147
+ it "stores the block and options" do
148
+ ctrlr.action :foo, options, &block
149
+ ctrlr.actions[:foo].should == {
150
+ :options => options,
151
+ :block => block
152
+ }
153
+ end
154
+
155
+ it "defaults options to an empty Hash" do
156
+ ctrlr.action :foo, &block
157
+ ctrlr.actions[:foo][:options].tap {|opts|
158
+ opts.should be_a(Hash)
159
+ opts.should be_empty
160
+ }
115
161
  end
116
162
  end
117
163
 
118
- context ".action(name, options = {}) { ... }" do
119
- let(:options) { {:foo => stub("foo option")} }
120
- let(:override_options) { {:bar => stub("bar option")} }
121
- let(:merged_options) { options.merge override_options }
122
- let(:env) { stub "env" }
123
- let(:ctrlr_obj) { stub "controller object", :response => response }
124
- let(:response) { stub "response", :finish => stub("finished response") }
164
+ context ".action(name, options = {})" do
165
+ let(:controller_options) {
166
+ {
167
+ :key1 => stub("value1 from controller"),
168
+ :key2 => stub("value2 from controller")
169
+ }
170
+ }
171
+ let(:action_options) {
172
+ {
173
+ :key2 => stub("value2 from action"),
174
+ :key3 => stub("value3 from action")
175
+ }
176
+ }
177
+ let(:call_options) {
178
+ {
179
+ :key3 => stub("value3 from call")
180
+ }
181
+ }
182
+ let(:merged_options) {
183
+ {
184
+ :key1 => controller_options[:key1],
185
+ :key2 => action_options[:key2],
186
+ :key3 => call_options[:key3],
187
+ :action => :foo
188
+ }
189
+ }
125
190
 
126
191
  before {
127
- ctrlr.action :foo, options, &block
128
- ctrlr.stub :new => ctrlr_obj
192
+ ctrlr.stub :options => controller_options
193
+ ctrlr.action(:foo, action_options, &block)
194
+ ctrlr_obj
129
195
  }
130
196
 
131
- it "creates an action proc" do
132
- ctrlr.action(:foo).should respond_to(:call)
197
+ it "merges controller, action and call options" do
198
+ ctrlr.should_receive(:new) {|env, options|
199
+ options.should == merged_options
200
+ ctrlr_obj
201
+ }
202
+ ctrlr.action(:foo, call_options).call env
133
203
  end
134
204
 
135
- it "'s proc creates a controller object passing env, options and block" do
136
- ctrlr.should_receive(:new) {|e, opts, &blk|
137
- e.should equal(env)
138
- opts.values_at(*merged_options.keys).should == merged_options.values
139
- blk.should equal(block)
205
+ it "adds the action's name to options" do
206
+ ctrlr.should_receive(:new) {|env, options|
207
+ options[:action].should equal(:foo)
208
+ ctrlr_obj
140
209
  }
141
- ctrlr.action(:foo).call env, override_options
210
+ ctrlr.action(:foo).call env
142
211
  end
143
212
 
144
- it "'s proc returns the finished response" do
145
- ctrlr.action(:foo).call(env).should equal(response.finish)
213
+ it "raises an ArgumentError if the specified action doesn't exist" do
214
+ proc { ctrlr.action(:i_dont_exist) }.should raise_error(ArgumentError)
146
215
  end
147
216
 
148
- it "'s proc adds the action's name to the options hash" do
149
- ctrlr.should_receive(:new) {|e, opts|
150
- opts[:action].should equal(:foo)
217
+ context "returns a proc that" do
218
+ let(:finished_response) { stub "response" }
219
+
220
+ before {
221
+ ctrlr.stub :new => ctrlr_obj
222
+ ctrlr_obj.response.stub :finish => finished_response
151
223
  }
152
- ctrlr.action(:foo).call env
153
- end
154
-
155
- it "'s proc returns nothing if a response gets passed in via options" do
156
- ctrlr.action(:foo).call(env, :response => response).should be_nil
224
+
225
+ it "creates a new controller object" do
226
+ ctrlr.should_receive(:new).with(env, merged_options)
227
+ ctrlr.action(:foo, call_options).call env
228
+ end
229
+
230
+ it "processes the action" do
231
+ ctrlr_obj.should_receive(:process) {|&blk|
232
+ block.should equal(blk)
233
+ ctrlr_obj
234
+ }
235
+ ctrlr.action(:foo).call env
236
+ end
237
+
238
+ it "returns the finished response" do
239
+ ctrlr.action(:foo).call(env).should equal(finished_response)
240
+ end
157
241
  end
158
242
  end
159
243
 
@@ -176,14 +260,19 @@ describe Pakada::Dispatch::Controller do
176
260
  "REQUEST_METHOD" => "bar"
177
261
  }
178
262
  }
263
+ let(:actions) {
264
+ {
265
+ :foo => stub("foo action"),
266
+ :bar => stub("bar action")
267
+ }
268
+ }
179
269
 
180
270
  before {
181
- ctrlr.action(:foo) {}
182
- ctrlr.action(:bar) {}
271
+ ctrlr.stub(:action) {|name| actions[name] }
183
272
  }
184
273
 
185
274
  it "sets default routing params" do
186
- ctrlr.action(:bar).should_receive(:call) {|e, opts|
275
+ actions[:bar].should_receive(:call) {|e, opts|
187
276
  e["router.params"].should == {}
188
277
  }
189
278
 
@@ -192,12 +281,12 @@ describe Pakada::Dispatch::Controller do
192
281
  end
193
282
 
194
283
  it "calls the action from routing params by default" do
195
- ctrlr.action(:foo).should_receive :call
284
+ actions[:foo].should_receive :call
196
285
  ctrlr.call env
197
286
  end
198
287
 
199
288
  it "calls the REQUEST_METHOD action as fallback" do
200
- ctrlr.action(:bar).should_receive :call
289
+ actions[:bar].should_receive :call
201
290
 
202
291
  env.delete "router.params"
203
292
  ctrlr.call env
@@ -1,9 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Pakada::Dispatch do
4
- let(:dispatch) { Pakada::Dispatch.new }
4
+ let(:dispatch) { Pakada[:dispatch] }
5
5
 
6
6
  context "#initialize" do
7
+ let(:dispatch) { Pakada::Dispatch.new }
7
8
  let(:router) { stub "router" }
8
9
 
9
10
  before {
@@ -13,22 +14,6 @@ describe Pakada::Dispatch do
13
14
  it "sets the router" do
14
15
  dispatch.router.should equal(router)
15
16
  end
16
-
17
- let(:controller) { Pakada.safety(Pakada::Dispatch::Controller) }
18
- let(:klass) { stub "controller klass" }
19
- let(:inner) { stub "proc", :call => nil }
20
-
21
- it "makes Controller and controllers hookable" do
22
- controller.should_receive(:around) {|method, &block|
23
- method.should equal(:included)
24
-
25
- klass.should_receive(:extend).with Hooked
26
- klass.should_receive(:include).with Hooked
27
- block.call inner, klass
28
- }
29
- dispatch
30
- controller.method :hooked
31
- end
32
17
  end
33
18
 
34
19
  context "#hooks" do
@@ -54,11 +39,8 @@ describe Pakada::Dispatch do
54
39
  }
55
40
 
56
41
  before {
57
- Pakada.instance.stub :modules => {
58
- :dispatch => dispatch,
59
- :module1 => module1,
60
- :module2 => module2
61
- }
42
+ Pakada.modules[:module1] = module1
43
+ Pakada.modules[:module2] = module2
62
44
  module1.stub :routes
63
45
  }
64
46
 
@@ -80,5 +62,27 @@ describe Pakada::Dispatch do
80
62
  module1.should_receive :routes
81
63
  dispatch.boot
82
64
  end
65
+
66
+ let(:context) { Pakada.safety(Pakada::Render::RenderingContext).new }
67
+
68
+ it "extends Pakada::Render::RenderingContext" do
69
+ dispatch.boot
70
+ context.should respond_to(:url)
71
+ end
72
+ end
73
+
74
+ context "#create_controller { ... }" do
75
+ it "creates a fresh controller class" do
76
+ dispatch.create_controller.tap {|cls|
77
+ controller = Pakada.safety(Pakada::Dispatch::Controller)
78
+ cls.included_modules.should include(controller, Hooked)
79
+ }
80
+ end
81
+
82
+ it "executes the block within the class' scope" do
83
+ dispatch.create_controller {
84
+ @foo = :foo
85
+ }.instance_variable_get(:@foo).should equal(:foo)
86
+ end
83
87
  end
84
88
  end
@@ -32,7 +32,7 @@ describe Pakada::Dispatch::Module do
32
32
 
33
33
  context "#controller(name) { ... }" do
34
34
  let(:block) { proc {} }
35
- let(:controller) { stub "controller", :before => nil }
35
+ let(:controller) { stub "controller", :options => {} }
36
36
  let(:dispatch) { Pakada::Dispatch.new }
37
37
 
38
38
  before {
@@ -40,28 +40,21 @@ describe Pakada::Dispatch::Module do
40
40
  }
41
41
 
42
42
  it "creates a controller class from the given block" do
43
- Pakada.safety(Pakada::Dispatch::Controller) \
44
- .should_receive(:create) {|&blk|
45
- blk.should equal(block)
46
- controller
47
- }
43
+ dispatch.should_receive(:create_controller) {|&blk|
44
+ blk.should equal(block)
45
+ controller
46
+ }
48
47
 
49
48
  mod.controller :bar, &block
50
49
  mod.controllers[:bar].should equal(controller)
51
50
  end
52
51
 
53
- let(:options) { {} }
54
-
55
- it "hooks the controller class' .new method to add module and controller name to options" do
56
- Pakada.safety(Pakada::Dispatch::Controller) \
57
- .should_receive(:create) { controller }
58
- controller.should_receive(:before) {|method, &blk|
59
- method.should equal(:new)
60
- blk.call nil, options
52
+ it "sets :module and :controller options" do
53
+ mod.controller :bar, &block
54
+ mod.controllers[:bar].options.tap {|options|
61
55
  options[:module].should equal(:foo)
62
56
  options[:controller].should equal(:bar)
63
57
  }
64
- mod.controller(:bar) {}
65
58
  end
66
59
  end
67
60
 
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe Pakada::Dispatch::RenderingContext do
4
+ let(:context) {
5
+ Object.new.tap {|o| o.extend Pakada::Dispatch::RenderingContext }
6
+ }
7
+
8
+ context "#url(route, params)" do
9
+ let(:params) { stub "params" }
10
+ let(:url) { stub "url" }
11
+
12
+ it "forwards to router.url" do
13
+ Pakada[:dispatch].router.should_receive(:url) {|route, prms|
14
+ route.should equal(:foo)
15
+ prms.should equal(params)
16
+ url
17
+ }
18
+ context.url(:foo, params).should equal(url)
19
+ end
20
+
21
+ it "defaults params to an empty Hash" do
22
+ Pakada[:dispatch].router.should_receive(:url) {|route, params|
23
+ params.should be_a(Hash)
24
+ params.should be_empty
25
+ }
26
+ context.url :foo
27
+ end
28
+ end
29
+ end
@@ -3,6 +3,7 @@ begin
3
3
  rescue LoadError; end
4
4
 
5
5
  require "pakada/dispatch"
6
+ require "pakada/render"
6
7
 
7
8
  RSpec.configure {|config|
8
9
  config.before {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakada-dispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-06 00:00:00.000000000Z
12
+ date: 2011-09-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakada
16
- requirement: &85649150 !ruby/object:Gem::Requirement
16
+ requirement: &78613870 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *85649150
24
+ version_requirements: *78613870
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: http_router
27
- requirement: &85648750 !ruby/object:Gem::Requirement
27
+ requirement: &78613560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *85648750
35
+ version_requirements: *78613560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack
38
- requirement: &85648260 !ruby/object:Gem::Requirement
38
+ requirement: &78613140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *85648260
46
+ version_requirements: *78613140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &85647280 !ruby/object:Gem::Requirement
49
+ requirement: &78612570 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *85647280
57
+ version_requirements: *78612570
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &85646720 !ruby/object:Gem::Requirement
60
+ requirement: &78612140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *85646720
68
+ version_requirements: *78612140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdiscount
71
- requirement: &85646210 !ruby/object:Gem::Requirement
71
+ requirement: &78587120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,18 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *85646210
79
+ version_requirements: *78587120
80
+ - !ruby/object:Gem::Dependency
81
+ name: pakada-render
82
+ requirement: &78586770 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *78586770
80
91
  description:
81
92
  email:
82
93
  - lars.gierth@gmail.com
@@ -95,12 +106,14 @@ files:
95
106
  - lib/pakada/dispatch.rb
96
107
  - lib/pakada/dispatch/controller.rb
97
108
  - lib/pakada/dispatch/module.rb
109
+ - lib/pakada/dispatch/rendering_context.rb
98
110
  - lib/pakada/dispatch/version.rb
99
111
  - pakada-dispatch.gemspec
100
112
  - spec/controller_spec.rb
101
113
  - spec/controllers/foo.rb
102
114
  - spec/dispatch_spec.rb
103
115
  - spec/module_spec.rb
116
+ - spec/rendering_context_spec.rb
104
117
  - spec/spec_helper.rb
105
118
  homepage: https://rubygems.org/gems/pakada-dispatch
106
119
  licenses: []