diff options
author | Gibheer <gibheer@gmail.com> | 2012-12-10 21:12:45 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2012-12-10 21:12:45 +0100 |
commit | e0919c87e56e26a5e079843d5dc4269844610a2b (patch) | |
tree | 3f43e5edd3f7d8a39e0375298d6ef238e64ffa21 | |
parent | 2e356837c2df8c8597f5f80f483dca0cc290032a (diff) |
define the renderer at initialization
-rw-r--r-- | lib/zero/controller.rb | 9 | ||||
-rw-r--r-- | spec/unit/controller/call_spec.rb | 7 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/zero/controller.rb b/lib/zero/controller.rb index cd9dbeb..f7c8d53 100644 --- a/lib/zero/controller.rb +++ b/lib/zero/controller.rb @@ -20,16 +20,17 @@ module Zero @@renderer end - # a small helper to get the actual renderer - def renderer - self.class.renderer - end + # the renderer which can be used to render templates + attr_reader :renderer # initialize the controller + # + # At initialization `@request`, `@response` and `@renderer` are set. # @param request [Request] a request object def initialize(request) @request = request @response = Zero::Response.new + @renderer = self.class.renderer end # build the response and return it diff --git a/spec/unit/controller/call_spec.rb b/spec/unit/controller/call_spec.rb index d62a3dc..9d2317e 100644 --- a/spec/unit/controller/call_spec.rb +++ b/spec/unit/controller/call_spec.rb @@ -1,9 +1,14 @@ require 'spec_helper' describe Zero::Controller, '.call' do - subject { SpecController.call(env) } + subject { controller.call(env) } + let(:controller) { SpecController } let(:env) { EnvGenerator.get('/foo') } + before :each do + controller.renderer = Object.new + end + it "returns a response" do subject.should be_respond_to(:to_a) end |