Lan*_*opp 14 ruby rspec stripe-payments
我正在尝试使用Rspec来删除Stripe API,我遇到了一个问题.这是我的代码的样子:
Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
Failure/Error: Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)
ArgumentError:
wrong number of arguments (0 for 3..6)
Run Code Online (Sandbox Code Playgroud)
Pet*_*vin 20
根据以下源代码,Stripe :: CardError需要3..6个参数:
class CardError < StripeError
...
def initialize(message, param, code, http_status=nil, http_body=nil, json_body=nil)
Run Code Online (Sandbox Code Playgroud)
以下是github上RSpec doc的关键文档:
expect(double).to receive(:msg).and_raise(error)
#error can be an instantiated object or a class
#if it is a class, it must be instantiable with no args
Run Code Online (Sandbox Code Playgroud)
因为你只是提供类和类需要参数,所以它失败了.您需要实例化它(即通过new)并提供参数.
| 归档时间: |
|
| 查看次数: |
5255 次 |
| 最近记录: |