今天我們看看怎么測試我們的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即可
安徽新華電腦學校專業職業規劃師為你提供更多幫助【在線咨詢】