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
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
资源分类: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
资源分类: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
**标题:“liblto_plugin-0.dll”** **描述解析:** `liblto_plugin-0.dll` 是一个动态链接库文件,对于MinGW(Minimalist GNU for Windows)编译环境来说至关重要。当用户尝试使用MinGW进行编译工作时,如果缺少这...
资源来自pypi官网。 资源全名:avocado_framework_plugin_i2n-77.0-py3-none-any.whl
python库。 资源全名:opensesame_plugin_Pulse_EVT2-0.0.6-py3-none-any.whl
资源来自pypi官网。 资源全名:qgis_plugin_ci-1.0.8-py3.7.egg
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project