原创作者: hideto   阅读:1033次   评论:0条   更新时间:2011-05-26    
今天我们看看怎么测试我们的helper方法:
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即可
评论 共 0 条 请登录后发表评论

发表评论

您还没有登录,请您登录后再发表评论

文章信息

Global site tag (gtag.js) - Google Analytics