`
hideto
  • 浏览: 2678409 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

每天一剂Rails良药之Write Tests for Your Helpers

    博客分类:
  • Ruby
阅读更多
今天我们看看怎么测试我们的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即可
分享到:
评论

相关推荐

    [Rails] Crafting Rails Applications (英文版)

    This pioneering book is the first resource that deep dives into the new Rails 3 APIs and shows you how use them to write better web applications and make your day-to-day work with Rails more ...

    Ruby+for+Rails

    **Ruby for Rails** Ruby是一种面向对象的动态编程语言,它以其简洁、优雅的语法和强大的元编程能力而闻名。在Web开发领域,Ruby与Rails框架的结合,即Ruby on Rails(RoR),开创了Web应用的新纪元。Ruby on Rails...

    ruby on rails for dummies

    《Ruby on Rails for Dummies》是一本专门为初学者设计的Ruby on Rails教程,它旨在帮助新手快速理解并掌握这个强大的Web开发框架。Ruby on Rails(简称Rails)是基于Ruby编程语言构建的一个开源Web应用程序框架,它...

    Ruby for Rails

    Ruby for Rails 英文原版, pdf格式 &lt;br&gt;本书是一部专门为Rails实践而写的经典Ruby著作,由四部分组成,共17章。第一部分讲述Ruby和Rails的编程环境。第二部分和第三部分与 Rails紧密联系,着重对Ruby这门语言...

    Rails.Angular.Postgres.and.Bootstrap.2nd.Edition

    Get your front end working with Webpack, use Postgres' features from migrations, and write unit tests for all of it. All of this within Rails 5. You'll gain the confidence to work at every level of ...

    Rails for Zombies

    Rails for Zombies是一份面向初学者的教程,通过学习本教程,用户能够掌握创建Ruby on Rails应用程序的基本知识。 Rails for Zombies教程中的"Deep in the CRUD"部分深入讲解了CRUD(创建Create、读取Retrieve、...

    Rails Recipes英文版(清晰文字pdf+源码)

    Ruby三神书之一(其余的两本是Agile.Web.Development.with.Rails和Ruby For Rails,在我的资源列表也有) Rails is large, powerful, and new. How do you use it effectively? How do you harness the power? And, ...

    rails和mysql数据库连接中出现的问题以及解决办法

    在开发Web应用时,Rails框架和MySQL数据库的集成是一个常见的选择。然而,有时在尝试连接Rails应用到MySQL数据库时,可能会遇到一些问题。本篇文章将深入探讨这些常见问题及其解决方案。 首先,Rails与MySQL的连接...

    rails 5 test prescriptions build a healthy codebase

    Your Ruby on Rails application is sick. Deadlines are looming, but every time you make the slightest change to the code, something else breaks. Nobody remembers what that tricky piece of code was ...

    rails2-sample

    从给定的文件信息来看,我们正在探讨的是一本关于Ruby on Rails的书籍,书名为《Simply Rails2》,作者是Patrick Lenz。本书旨在为初学者提供深入理解Ruby on Rails框架的指南,从基础概念到高级主题均有涵盖,是...

    Rails 101 入门电子书

    《Rails 101 入门电子书》是一本非常适合初学者直接入门的书籍,它由xdite编写并出版于2014年6月10日。本书主要针对的是希望学习Ruby on Rails框架的读者,特别是那些想要从零开始掌握这项技术的新手。 #### 二、...

    Rails101_by_rails4.0

    《Rails101_by_rails4.0》是一本专注于Rails 4.0.0版本和Ruby 2.0.0版本的自学教程书籍,它定位于中文读者,旨在成为学习Rails框架的参考教材。Rails(Ruby on Rails)是一个采用Ruby语言编写的开源Web应用框架,它...

    Bootstrap for Rails

    Bootstrap for Rails is for Rails web developers who are struggling to get their website designs right. It will enable you to create beautiful responsive websites in minutes without writing much CSS ...

Global site tag (gtag.js) - Google Analytics