Consider, for example, the following code:
class ViewHelpersTest < ActionView::TestCase
should 'generate tag with correct parameters' do
assert_equal theme_stylesheet_link_tag('style', :media => 'print'),
'<link href="/themes/default/stylesheets/style.css" media="print" rel="stylesheet" type="text/css" />'
end
end
current_theme_stylesheet_tagis a view helper that creates a style sheet link tag that points to a css file located inside the current theme directory. You can get the current topic by calling ApplicationController::current_theme.
So, I need to provide a valid controller instance that brings me to my question:
How to specify the exact controller to use when testing view helpers in Rails 3?
Also, if there is a better way to express this test, please let me know. I have little testing experience.
source
share