【发布时间】:2011-02-11 14:57:48
【问题描述】:
在我的 Rails 3 应用程序中,我有一个具有以下操作的控制器(代码简化):
def payment
redirect_to some_url_of_an_external_website
end
# the external website redirects the browser to this action when the payment is done
def payment_callback
@subscription = Subscription.new(:subscription_id => params[:subscription_id])
...
end
在我的验收测试中(使用steak 和RSpec 2),当水豚跟随指向payment 操作的链接时,我想避免重定向到这个外部URL。基本上我想模拟路由助手payment_path,使其直接指向payment_call_path,并带有适当的subscription_id 参数。
这是正确的方法吗?如果是这样,我该如何模拟 payment_path (找不到怎么做)?
【问题讨论】:
标签: ruby-on-rails mocking rspec integration-testing