简体   繁体   中英

Testing Braintree Transparent Redirect for Rails App

I'm using Braintree Transparent Redirect to take payment info and create subscriptions that are stored with Braintree. What are best practices for testing the controller that interacts with Braintree? It seems like a lot of trouble to create a new customer and subscription in the Braintree sandbox every time I run my test. I'm using Rspec if that matters at all.

If you're still interested in using Rspec, check out the braintree ruby examples on github. All the tests are rspec, and there are lots of examples you can use.

https://github.com/braintree/braintree_ruby_examples

嘿,尝试一下,现在就自己设置BT,并计划大致以这种方式进行测试: http : //www.enlightsolutions.com/articles/integration-testing-braintrees-transparent-redirect-with-rails-和黄瓜/

You can use fake_braintree to speed up your tests.

"This library is a way to test Braintree code without hitting Braintree's servers. It uses Capybara::Server to intercept all of the calls from Braintree's Ruby library and returns XML that the Braintree library can parse. The whole point is not to hit the Braintree API."

Or, if it doesn't do all you need, you can use Capybara with either the default java script driver or the capybara-webkit gem to test the transparent redirects.

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