今天我们看看怎么测试我们的helper方法:
通过include ApplicationHelper,则该类里面定义的所有方法都可以作为本地方法得到
如果想测试其它类里面的helper方法,我们只需要将该类include即可
- require File.dirname(__FILE__) + '/../test_helper'
- class HelperTest < Test::Unit::TestCase
- include ActionView::Helpers::UrlHelper
- include ActionView::Helpers::TextHelper
- include ActionView::Helpers::TagHelper
- include ApplicationHelper
- # include whatever helpers you want to test here, sometimes you'll need
- # to include some of the Rails helpers, as I've done above.
- def test_some_helper
- end
- end
通过include ApplicationHelper,则该类里面定义的所有方法都可以作为本地方法得到
如果想测试其它类里面的helper方法,我们只需要将该类include即可
安徽新华电脑学校专业职业规划师为你提供更多帮助【在线咨询】