Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Add Tests #2

Open
craysiii opened this issue Dec 13, 2017 · 3 comments
Open

Add Tests #2

craysiii opened this issue Dec 13, 2017 · 3 comments

Comments

@craysiii
Copy link
Owner

We need tests.

Currently outside of the repo, I have tests that run on the actual API. I would like to stub out these requests, but I'm not really sure how to go about that, especially considering the fact that the Account_API and Withdraw_API rely on credentials.

Any suggestions welcome.

@cmer
Copy link

cmer commented Jan 31, 2018

I'd be willing to help make this happen. Are you able to send me your tests (privately)?. You can remove the creds of course.

@craysiii
Copy link
Owner Author

craysiii commented Feb 3, 2018

Hey @cmer - sorry for the late response.

Unfortunately I lost my personal tests when I switched from developing on Windows to WSL. Stupid mistake. Anyway, feel free to start from scratch, or I can write up some basic stuff this weekend and we can build on that. I will ask that you use RSpec.

Quick question: Do you plan to mock? I have been eyeing VCR, doesn't really matter to me what you use though. I have implemented passing Faraday adapters to the REST API, so we can also pass Faraday::Adapter::Test::Stubs instances.

@kke
Copy link
Contributor

kke commented Mar 17, 2018

VCR is a waste of time as the client does not care about the responses, it returns raw json. It adds nothing if you write tests that expect the response to be what you told the webmock library to return. Then you're just testing the webmock library.

The gem does not try to convert string prices and quantities to floats or anything. You must do everything by yourself. It's just a list of endpoints and which security measures they require and what parameters are supported/required by it.

There's very little magic so also very little to test.

You can just stub the client calls and expect the client to be called with certain params if you want to write specs for the endpoint methods.

There are only a couple of things that should be tested:

  1. the api key header gets sent
  2. the timestamp is added
  3. the requests are correctly signed

The http request internals are already tested in Faraday, no need to re-test.
The websocket internals are already tested in Faye, no need to re-test.

If you add magic and do something with the responses, there's more to test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants