Skip to content

Commit

Permalink
Merge pull request #47 from marcandre/camelize
Browse files Browse the repository at this point in the history
Camelize instead of classify
  • Loading branch information
José Valim committed Jun 7, 2012
2 parents b176bb2 + 8c55252 commit 6edf2ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/responders/controller_method.rb
Expand Up @@ -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
Expand All @@ -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 changes: 8 additions & 8 deletions test/controller_method_test.rb
Expand Up @@ -16,7 +16,7 @@ def to_html
end
end

module BazResponder
module PeopleResponder
def to_html
@resource << "baz"
super
Expand All @@ -25,7 +25,7 @@ def to_html

class PeopleController < ApplicationController
responders :foo, BarResponder

def index
@array = []
respond_with(@array) do |format|
Expand All @@ -35,7 +35,7 @@ def index
end

class SpecialPeopleController < PeopleController
responders :baz
responders :people
end

class ControllerMethodTest < ActionController::TestCase
Expand All @@ -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"
Expand All @@ -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.