Baraa Al-Bourghli
Baraa Al-Bourghli

Reputation: 126

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.

Upvotes: 1

Views: 751

Answers (1)

Baraa Al-Bourghli
Baraa Al-Bourghli

Reputation: 126

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

Upvotes: 1

Related Questions