ruby 可安装的发动机Rspec控制器测试
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 可安装的发动机Rspec控制器测试相关的知识,希望对你有一定的参考价值。
module ControllerHacks
def get(action, parameters = nil, session = nil, flash = nil)
process_action(action, parameters, session, flash, "GET")
end
# Executes a request simulating POST HTTP method and set/volley the response
def post(action, parameters = nil, session = nil, flash = nil)
process_action(action, parameters, session, flash, "POST")
end
# Executes a request simulating PUT HTTP method and set/volley the response
def put(action, parameters = nil, session = nil, flash = nil)
process_action(action, parameters, session, flash, "PUT")
end
# Executes a request simulating DELETE HTTP method and set/volley the response
def delete(action, parameters = nil, session = nil, flash = nil)
process_action(action, parameters, session, flash, "DELETE")
end
private
def process_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
parameters ||= {}
process(action, parameters.merge!(:use_route => :my_engine), session, flash, method)
end
end
RSpec.configure do |c|
c.include ControllerHacks, :type => :controller
end
以上是关于ruby 可安装的发动机Rspec控制器测试的主要内容,如果未能解决你的问题,请参考以下文章
新入手一枚测试工具:rspec
ruby [rspec]“使用RSpec测试Rails程序”笔记
调试 Rspec Postgres 锁定
ruby ruby rspec测试示例
使用 Rspec 测试 Rails 3.1 可安装引擎
ruby Rspec测试的最大命中:第1卷