[英]Rails PayPal IPN activemerchant controller rspec test
I have a PayPal API implemented in my system using activemerchant gem, i want to write some specs to test it, i have searched alot for an example but i didn't find any, i want to fully test the create action with a fake PayPal message, i tried this : 我有一个使用activemerchant gem在我的系统中实现的PayPal API,我想编写一些规范对其进行测试,我搜索了很多示例,但没有找到任何示例,我想使用一个伪造的PayPal来全面测试create操作消息,我尝试了这个:
ActiveMerchant::Billing::Integrations::Paypal::Notification.any_instance.stub('acknowledge').and_return(true)
But then the test entered an infinite loop and returned this error : 但是随后测试进入无限循环并返回此错误:
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
I searched the internet many times but i didn't find an example or a reference on how to mock the PayPal message, any help would be appreciated. 我在互联网上搜索了很多次,但是没有找到有关如何模拟PayPal消息的示例或参考,希望能对您有所帮助。 Thanks.
谢谢。
I found a solution, the only mistake that i did is that i didn't stub the method using symbol naming, i mistakenly used this: 我找到了一个解决方案,我唯一的错误是我没有使用符号命名对方法进行存根,我错误地使用了此方法:
any_instance.stub('acknowledge')
instead of this: 代替这个:
any_instance.stub(:acknowledge)
I also wrote an example of how to test IPN in Rspec 我还写了一个如何在Rspec中测试IPN的示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.