Mangopay / mangopay2-ruby-sdk

Ruby Gem for MANGOPAY
https://rubygems.org/gems/mangopay
MIT License
42 stars 38 forks source link

Testing recommendations #37

Closed jlecour closed 8 years ago

jlecour commented 8 years ago

Hi,

I was wondering what is the recommended testing strategy when using this gem. I've been using it within an application for basic hand-tested features, but now I need to implement more complexe behavior and I want to set up automated tests.

It would be nice if the gem provided some stubs (and ideally some matchers too), in the same spirit as the fake credit cards provided for payments in the sandbox environment.

Thank you for providing this SDK. :clap:

seuros commented 8 years ago

You can use the hardcoded key for your tests.

jlecour commented 8 years ago

@seuros Hey, I'm intrigued. Did I miss something obvious ? I know nothing about an hard-coded key.

seuros commented 8 years ago

https://github.com/Mangopay/mangopay2-ruby-sdk/blob/master/spec/spec_helper.rb

jlecour commented 8 years ago

I'll try that and report back. Thank you @seuros.

hobailey commented 8 years ago

Thanks for your help @seuros. @jlecour I'll close this for now, but do come back to us if you have any further queries.

jlecour commented 8 years ago

It remains a bit unclear to me how I should test my implementation code.

What special behavior is triggered by the key cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju ? Is it just a special account that is pruned every now and then (like a testing database) ?

Thanks

hobailey commented 8 years ago

@jlecour there is no special behaviour with this account (ClientId and Passphrase) given in https://github.com/Mangopay/mangopay2-ruby-sdk/blob/master/spec/spec_helper.rb (ie no pruning/modifications made on our side unless you ask us to). It's just a test account like any other account in sandbox. You can create your own test account if you like at https://www.mangopay.com/signup/create-sandbox/

javiercr commented 8 years ago

@jlecour we use a sandbox account (like the one used by the gem itself) and then record the requests with VCR so that future test runs do not need to hit the API.

For recording front-end requests (like tokenizing the credit card) we use Puffing Billy.