[英]Rails PayPal IPN activemerchant controller rspec test
我有一个使用activemerchant gem在我的系统中实现的PayPal API,我想编写一些规范对其进行测试,我搜索了很多示例,但没有找到任何示例,我想使用一个伪造的PayPal来全面测试create操作消息,我尝试了这个:
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消息的示例或参考,希望能对您有所帮助。 谢谢。
我找到了一个解决方案,我唯一的错误是我没有使用符号命名对方法进行存根,我错误地使用了此方法:
any_instance.stub('acknowledge')
代替这个:
any_instance.stub(:acknowledge)
我还写了一个如何在Rspec中测试IPN的示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.