简体   繁体   中英

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::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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM