I extract the plugin from a real project
http://code.google.com/p/railsjob/ to make test easier.
I submit it to
http://agilewebdevelopment.com/plugins/test_helpfulAnd write a short document -- sorry for my ugly English. :p
TestHelpful
===========
This plugin provide the following helper method for test
# Functional Matrix Test support
To knowlearn about it: http://www.infoq.com/news/2007/04/matrix-your-tests
This plugin modify the matrix test code of ZenTest and add some new feature.
* You need not to define matrix_init_xxx method, but init with block:
In your test case:
def setup
init(:logined){ login_as :dongbin}
end
then "login_as :dongbin" will be called when setup include "logined"
* Reuse your test with after_filter
In your test case
after_filter :render_form, :new, :edit
def matrix_test_render_form
assert_response :success
assert assigns(:job)
assert_form(assigns(:job), *@@job_default_attr.keys)
end
def matrix_test_new
assert_template 'new'
end
def matrix_test_edit
assert_template 'edit'
end
Then matrix_test_render_form will be called after matrix_test_new or matrix_test_edit
# assert_form
Note: This method can only work with edge rails(Rails 2.0)
assert_form(@user, :email, :password)
equals to
assert_select("form[action=/users]") do
assert_select("#user_email[name=?]", "user[email]")
assert_select("#user_password[name=?]", "user[password]")
assert_select("input[type=submit]")
end
# Add a method named "create" for unit tests and functional tests
* For Unit Test
in UserTest
create(:name => 'dongbin')
equals to
User.create(@@user_default_attr.merge(:name => 'dongbin')
If @@user_default_attr not defined, then it is an empty {}
* For functional test
In UserControllerTest
create(:name => 'dongbin')
equals to
post :create, :user => @@user_default_attr.merge(:name => 'dongbin')
If @@user_default_attr not defined, then it is an empty {}
Example
http://railsjob.googlecode.com/svn/trunk/test/functional/jobs_controller_test.rb
Copyright (c) 2007 Bin Dong<dongbin.cn@gmail.com>, released under the MIT license
分享到:
相关推荐
RenPyPlugin-8.0.3_7.5.3_009-patreon-release .apk
标题中的"axis2-idea-plugin-1.7.9.zip_axis2_axis2-idea-plugin_idea导入axis2_"提到了几个关键元素,分别是"axis2"、"idea-plugin"和"idea导入axis2",这暗示了这个压缩包是用于在IntelliJ IDEA这款集成开发环境...
ruby_file_jekyll-paginate-plugin
资源分类:Python库 所属语言:Python 资源全名:nonebot_plugin_shindan-0.2.2-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
lua for windows其实是一整套Lua的开发环境.Lua for Windows 为 Windows 系统下提供了 Lua 脚本语言的开发和运行环境。Lua 是一个小巧的脚本语言。作者是巴西人。该语言的设计目的是为了嵌入应用程序中,从而为应用...
pillow_avif_plugin-1.2.2-pp38-pypy38_pp73-win_amd64.whl
pillow_avif_plugin-1.2.0-pp37-pypy37_pp73-win_amd64
Packer_plugin_for_VritualBox_Builder_Packer-plugin-virtualbox_Packer_plugin_for_VritualBox_Builder_packer-plugin-virtualbox
**标题:“liblto_plugin-0.dll”** **描述解析:** `liblto_plugin-0.dll` 是一个动态链接库文件,对于MinGW(Minimalist GNU for Windows)编译环境来说至关重要。当用户尝试使用MinGW进行编译工作时,如果缺少这...
「漏洞分析」信息安全_数据安全_2_ZN2018_WV_-_Blind_Xss_(femida_plugin - 安全研究 企业安全 基础架构安全 漏洞挖掘 防火墙 业务安全
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:nonebot_plugin_cocdicer-0.2.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:nonebot_plugin_puppet-0.1.4-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
java编程必备 第六版 大小为16M.
资源分类:Python库 所属语言:Python 资源全名:pybpod_gui_plugin_soundcard-0.1.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
7. **plugin_host-3.8.exe和plugin_host-3.3.exe**:这两个是Sublime Text的插件主机程序,分别对应不同版本。它们负责运行用户的插件代码,使Sublime Text能够提供丰富的自定义功能和扩展性。 综上所述,Sublime ...
资源分类:Python库 所属语言:Python 资源全名:netbox_plugin_test-0.4-py3.7.egg 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
python库。 资源全名:nonebot_plugin_russian-0.1.2-py3-none-any.whl
gem 'to_xls-rails' # Last officially released gem # gem "to_xls-rails", :git => "git://github.com/liangwenke/to_xls-rails.git" # Track git repo 或者,作为宝石安装: gem install to_xls - rails 或者,...
资源来自pypi官网。 资源全名:avocado_framework_plugin_i2n-77.0-py3-none-any.whl