【发布时间】:2014-07-29 01:12:58
【问题描述】:
我有一个控制器,它有一个名为create 的 POST 操作。在创建操作中,我使用 puntopagos gem 类 (PuntoPagos::Request),该类使用 rest-client gem 向 API 发送 POST:
class SomeController < ApplicationController
def create
request = PuntoPagos::Request.new
response = request.create
#request.create method (another method deeper, really)
#does the POST to the API using rest-client gem.
if response.success?
#do something on success
else
#do something on error
end
end
end
如何使用 RSpec 存根其余客户端请求和响应以测试我的创建操作?
【问题讨论】:
标签: ruby-on-rails testing rspec stub rspec3