dandemeyere/responsys-api — pull request #16 by florrain (2014-11-06 17:49:28+00:00)
Title: login/logout wrapping up all calls + More straightforward RSpec tests.

@12and1studio Hope it can help for the tests. Can you :+1: ?
@evantahler @bleonard can you guys :+1: especially at the new session handling as evoked in the issue [#10](https://github.com/dandemeyere/responsys-api/issues/10) ?

## Description
In some conditions, the session handling can generate a lot of zombie sessions that are created once and then never killed using the `logout` function. This changes that by wrapping each call inside a `login / call / logout` holiday box.

Also, related to the session I wanted to make the tests easier. Currently (almost) all tests are bound to our (thredUP) account. It is tricky to add tests or even edit them without getting inside the cassettes to remove the credentials.
I tried to make the data out of the tests and also the credentials out of the vcr cassettes. More details below.

## Session
The main changes are in the API `client.rb`, especially the `api_method` that is used by most of the calls.

## Tests
- vcr only records the request if it's not a `login` request. So no credentials are stored in the cassettes.
- the dev credentials must be put in a `api_credentials.yml`. As an example you can use the `api_credentials_sample.yml`.
- The tests don't refer to actual hard coded data but to a YML file where are stored the values that should be used by every devs.
So if you're a new dev or you haven't setup your responsys account for the dev, please create the objects described in the YML in your actual account. You can then refer in your tests to it with: `DATA[:key]`.

Suggestions/remarks ?

Thanks