linux 基础(第三天)
2011-04-18 22:32
141 查看
初次接触Rspec 发现网上基本资料少的可怜 找到点啥先记下备用~
assert_template 测试是否装载了正确的view
assert_tag 'form',:attributes=>{:action=>'/admin/....'} 测试View中是否有这表单,form也可以是div,td,input等html元素。
assert_response :redirect
assert_redirected_to :action=>'index' 重定向
assigns(:author).first_name :assign是辅助方法,检查author实例变量的赋值。它是个测试辅助方法,用来存取最后请求的动作里所有实例变量的赋值。
follow_redirect Rails自带的测试辅助方法,它使测试用例可以跟随控制器里的redirect_to调用到哪个目标页面。
测试 render :text => "string"
测试 render :nothing => true
测试ajax请求
assert_template 测试是否装载了正确的view
assert_tag 'form',:attributes=>{:action=>'/admin/....'} 测试View中是否有这表单,form也可以是div,td,input等html元素。
assert_response :redirect
assert_redirected_to :action=>'index' 重定向
assigns(:author).first_name :assign是辅助方法,检查author实例变量的赋值。它是个测试辅助方法,用来存取最后请求的动作里所有实例变量的赋值。
follow_redirect Rails自带的测试辅助方法,它使测试用例可以跟随控制器里的redirect_to调用到哪个目标页面。
测试 render :text => "string"
response.body.should == "string"
测试 render :nothing => true
response.should have_text(" ")
测试ajax请求
describe 'get/post 你的action的名称 using ajax' do it 'should render template 模板名称' do xhr :post, :action的名称, 其它需要传递给action的值的hash response.should render_template('渲染的模板') end end describe 'get/post 你的action的名称 using html' do it 'should reject access using html' do get/post ::action的名称, 其它需要传递给action的值的hash response.response.should == 406 end end
相关文章推荐
- Python学习第三天----Linux基础命令
- 跟我一起学linux基础(第三天)
- 嵌入式开发之Linux基础第三天学习笔记 linux系统命令(二)
- linux驱动学习--第三天:驱动设计的硬件基础
- 七天LLVM零基础入门(Linux版本)------第三天
- 七天LLVM零基础入门(Linux版本)------第三天
- linux基础学习-第三天记录
- Linux多线程基础学习(六)线程属性
- Linux开发基础:Shell编程入门(二)
- Linux学习日记 —— 10.4.3 Shell基础-Bash变量-位置参数变量
- 零基础Linux定时shell脚本
- Linux线程的基础知识
- Linux基础最实用部分详细
- linux-14基础命令之-复制(cp)移动(mv),删除(rm),拷贝文件(dd)
- LinuxC/C++编程基础(35) std::istream使用实例
- 【Linux基础】文件相关命令
- 目前最完整的Linux常用基础命令
- Linux-27-linux基础重要命令04(L005-09)
- linux安全基础:设置系统超时
- linux基础之spi驱动程序理解