Permalink
Browse files

Merge pull request #47 from marcandre/camelize

Camelize instead of classify
  • Loading branch information...
josevalim committed Jun 7, 2012
2 parents b176bb2 + 8c55252 commit 6edf2eff9efaa8b082254e3f189e3e00a66e0034
Showing with 12 additions and 12 deletions.
  1. +4 −4 lib/responders/controller_method.rb
  2. +8 −8 test/controller_method_test.rb
@@ -2,7 +2,7 @@ module Responders
module ControllerMethod
# Adds the given responders to the current controller's responder, allowing you to cherry-pick
# which responders you want per controller.
#
#
# class InvitationsController < ApplicationController
# responders :flash, :http_cache
# end
@@ -22,16 +22,16 @@ def responders(*responders)
when Module
responder
when String, Symbol
Responders.const_get("#{responder.to_s.classify}Responder")
Responders.const_get("#{responder.to_s.camelize}Responder")
else
raise "responder has to be a string, a symbol or a module"
end
klass.send(:include, responder)
klass
end
end
end
end
ActionController::Base.extend Responders::ControllerMethod
ActionController::Base.extend Responders::ControllerMethod
@@ -16,7 +16,7 @@ def to_html
end
end
module BazResponder
module PeopleResponder
def to_html
@resource << "baz"
super
@@ -25,7 +25,7 @@ def to_html
class PeopleController < ApplicationController
responders :foo, BarResponder
def index
@array = []
respond_with(@array) do |format|
@@ -35,7 +35,7 @@ def index
end
class SpecialPeopleController < PeopleController
responders :baz
responders :people
end
class ControllerMethodTest < ActionController::TestCase
@@ -49,7 +49,7 @@ def test_foo_responder_gets_added
get :index
assert assigns(:array).include? "foo"
end
def test_bar_responder_gets_added
get :index
assert assigns(:array).include? "bar"
@@ -58,15 +58,15 @@ def test_bar_responder_gets_added
class ControllerMethodInheritanceTest < ActionController::TestCase
tests SpecialPeopleController
def setup
@controller.stubs(:polymorphic_url).returns("/")
@controller.stubs(:polymorphic_url).returns("/")
end
def test_responder_is_inherited
get :index
assert assigns(:array).include? "foo"
assert assigns(:array).include? "bar"
assert assigns(:array).include? "baz"
end
end
end

0 comments on commit 6edf2ef

Please sign in to comment.