I’m using template components to modularize an application I’m working
on and am really happy with the way it’s going. Unfortunately, all my
attempts at writing functional tests for them fail. Trying to duplicate
my normal controller tests I have:
require File.dirname(FILE) + ‘/…/test_helper’
require File.dirname(FILE) + ‘news_controller’
Re-raise errors caught by the controller.
class NewsController; def rescue_action(e) raise e end; end
class NewsControllerTest < Test::Unit::TestCase
def setup
@controller = NewsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
Replace this with your real tests.
def test_content
get :content
assert_response :success
assert_rendered_file “content”
end
end
But running that gives me:
- Error:
test_content(NewsControllerTest):
NoMethodError: undefined method `controller_path’ for
NewsController:Class
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/test_process.rb:295:in
`process’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/test_process.rb:307:in
get' news_controller_test.rb:16:in
test_content’
So, I’m guessing I can’t use get() with components? Any advice?
Thanks,
Mike