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:
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
Any ideas?
Thanks!
Clem R. wrote:
module BlogController
[/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