Clem Rock wrote:> Hello,
>
> I have a controller that defines a module and I''m wondering how
I can
> write a functional test for methods w/in the module.
>
> Here''s the basic structure of the controller module
blog_controller:
>
> [code]
> require ''hmac/hmac-sha2''
>
> module BlogController
> PAGEXI_HMAC_SHA256_KEY = "sdfqaasdfwfa3rq32aq"
> PAGEXI_HMAC_SHA256_AUTHOR_KEY = "sooloo"
>
> def combined
> render :partial => "/blog/page_object_combined"
> end
>
> #etc...
> end
>
> [/code]
>
> Any ideas?
>
> Thanks!
>
I usually set up a test for that module, and in the test file define a
Dummy Controller that includes the module and has only the most basic
functionality (e.g. an action with render :text "hello world"). Have a
look at some of the tests in Rails itself, e.g. the redirect tests in
rails/action_pack/test/controller/redirect_test.rb
You can also do some unit testing of the Dummy Controller instance
(that''s available via the @controller instance variable -- e.g.
@controller.respond_to?(:combined). If you do a bit of googling for
something like "testing application controller" there''s some
info
somewhere on how to test methods defined in the AC, and that should
steer you in the right direction also.
Hope this helps
Chris
--
----------------------------
Autopendium :: Stuff about old cars
http://autopendium.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---