diff options
-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 |