Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 29, 2013
@Gibheer Gibheer don't use class_options for the time being 4a4d68d
@Gibheer Gibheer make request and response static
This is a step back but makes the controller work for the moment. It
should be reimplemented in a better way in the future.
a2aed1f
View
2 Gemfile
@@ -2,8 +2,6 @@ source 'https://rubygems.org'
gemspec
-gem 'class_options', :git => 'https://github.com/Gibheer/class_options.git'
-
group :development do
gem 'devutils-guard'
View
10 Gemfile.lock
@@ -1,9 +1,3 @@
-GIT
- remote: https://github.com/Gibheer/class_options.git
- revision: 38cb6da00a9aa613eb7510145345cd5eb3c06614
- specs:
- class_options (0.0.2)
-
PATH
remote: .
specs:
@@ -14,6 +8,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
+ class_options (0.0.1)
coderay (1.0.8)
devutils (0.0.1)
rspec
@@ -50,7 +45,7 @@ GEM
method_source (~> 0.8)
slop (~> 3.4)
spoon (~> 0.0)
- rack (1.5.0)
+ rack (1.5.1)
redcarpet (2.2.2)
rspec (2.12.0)
rspec-core (~> 2.12.0)
@@ -72,7 +67,6 @@ PLATFORMS
ruby
DEPENDENCIES
- class_options!
devutils
devutils-docs
devutils-guard
View
21 lib/zero/controller.rb
@@ -11,16 +11,17 @@ def self.call(env)
new(env).response
end
- # set the class to use for responses
- accept_options :response
-
- # set a class to use for requests
- accept_options :request
+ # set the renderer to use for rendering
+ def self.renderer=(renderer)
+ @@renderer = renderer
+ end
- # set the renderer to use in the controller
- accept_options :renderer
+ # returns the defined renderer
+ def self.renderer
+ @@renderer
+ end
- # the renderer which can be used to render templates
+ # returns the current renderer
attr_reader :renderer
# initialize the controller
@@ -29,8 +30,8 @@ def self.call(env)
# renderer, request and response.
# @param env [Hash] a rack compatible environment
def initialize(env)
- @request = self.class.request.new(env)
- @response = self.class.response.new
+ @request = Zero::Request.new(env)
+ @response = Zero::Response.new
@renderer = self.class.renderer
end
View
20 spec/unit/zero/controller/call_spec.rb
@@ -6,13 +6,11 @@
let(:env) { EnvGenerator.get('/foo') }
before :each do
- object.renderer(Object.new)
- object.response(Zero::Response)
- object.request(Zero::Request)
+ object.renderer = Object.new
end
it "returns a response" do
- subject.should be_respond_to(:to_a)
+ subject.should respond_to(:to_a)
end
it "returns an object with the first element being a status" do
@@ -26,18 +24,4 @@
r = Zero::Request.new(env)
expect(r.params['foo']).to eq('bar')
end
-
- context "with the response" do
- let(:response_class) { mock }
- before :each do
- object.response(response_class)
- response_class.should_receive(:new).and_return(Zero::Response.new)
- end
-
- after :each do
- Zero::Controller.response(nil)
- end
-
- it { subject }
- end
end
View
9 spec/unit/zero/controller/render_spec.rb
@@ -4,22 +4,17 @@
let(:object) { create_controller }
subject { object.new(env) }
- before do
- object.request(Zero::Request)
- object.response(Zero::Response)
- end
-
let(:env) { EnvGenerator.get('/foo') }
let(:renderer) { mock }
let(:template) { '/foo' }
before :each do
- object.renderer(renderer)
+ object.renderer = renderer
renderer.should_receive(:render).with(template,
kind_of(Zero::Request::AcceptType), subject)
end
after :each do
- Zero::Controller.renderer(nil)
+ Zero::Controller.renderer = nil
end
it { subject.render(template) }
View
8 spec/unit/zero/controller/renderer_spec.rb
@@ -4,14 +4,8 @@
subject { create_controller }
let(:renderer) { Object.new }
- before do
- subject.response(Zero::Response)
- subject.request(Zero::Request)
- end
-
it 'returns the set renderer' do
- subject.renderer(renderer)
- p subject.renderer
+ subject.renderer = renderer
expect(subject.new({}).renderer).to be(renderer)
end
end

No commit comments for this range

Something went wrong with that request. Please try again.