我有一个名为 POST 操作的控制器create
。在创建操作中,我使用了一个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 存根其余客户端请求和响应以测试我的创建操作?