【问题标题】:Rails PayPal IPN activemerchant controller rspec testRails PayPal IPN activemerchant 控制器 rspec 测试
【发布时间】:2014-01-26 04:33:47
【问题描述】:

我在我的系统中使用 activemerchant gem 实现了一个 PayPal API,我想编写一些规范来测试它,我已经搜索了很多示例但我没有找到任何示例,我想完全测试创建操作一条虚假的 PayPal 消息,我试过这个:

ActiveMerchant::Billing::Integrations::Paypal::Notification.any_instance.stub('acknowledge').and_return(true)

但随后测试进入了无限循环并返回了这个错误:

 Api::PaypalIpnController GET create update the order from pending to complete
 Failure/Error: Unable to find matching line from backtrace
 SystemStackError:
   stack level too deep

我在互联网上搜索了很多次,但没有找到有关如何模拟 PayPal 消息的示例或参考,我们将不胜感激。 谢谢。

【问题讨论】:

    标签: ruby-on-rails rspec paypal-ipn activemerchant


    【解决方案1】:

    我找到了一个解决方案,我唯一的错误是我没有使用符号命名来存根方法,我错误地使用了这个:

      any_instance.stub('acknowledge')
    

    而不是这个:

      any_instance.stub(:acknowledge)
    

    我还写了how to test IPN in Rspec的例子

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多