Conversation
Generated by 🚫 Danger |
pmn4
left a comment
There was a problem hiding this comment.
I hadn't used VCR before... thanks for the introduction! it is a fantastic tool for writing specs!
| module Errors | ||
| class SymbolNotFoundError < StandardError | ||
| attr_reader :symbol | ||
| class IexError < StandardError |
There was a problem hiding this comment.
added an Error superclass to allow for other projects to:
rescue IEX::Errors::IexErrorinstead of having to:
rescue IEX::Errors::SymbolNotFoundError, IEX::Errors::SearchNotFoundError, ... # as more errors are addedThere was a problem hiding this comment.
tbh, I hadn't realized there were other errors defined (I thought I was creating the second one). If I had, I probably would have put this into a separate PR. sorry for the confusion!
spec/iex/client_spec.rb
Outdated
| end | ||
| end | ||
|
|
||
| context '#search' do |
There was a problem hiding this comment.
tests for this endpoint were added to client_spect.rb because other endpoints have associated resources, where #search (eventually, according to the documentation) returns any type of resource.
There was a problem hiding this comment.
Make a directory, search and create search/quote_spec.rb and such? For the general use case of errors make a search_spec.rb.
dblock
left a comment
There was a problem hiding this comment.
This is great and is on the right track! See comments. Also needs README documentation.
| http_interactions: | ||
| - request: | ||
| method: get | ||
| uri: https://sandbox.iexapis.com/v1/search/?token=Tsk_341c973d296e4e18aa61dd63050ce235 |
There was a problem hiding this comment.
Remove your actual token from here.
spec/iex/client_spec.rb
Outdated
| end | ||
| end | ||
|
|
||
| context '#search' do |
There was a problem hiding this comment.
Make a directory, search and create search/quote_spec.rb and such? For the general use case of errors make a search_spec.rb.
spec/iex/client_spec.rb
Outdated
| # order for VCR to record the response, we need the endpoint to work | ||
| client.endpoint = 'https://sandbox.iexapis.com/v1' | ||
| # using the documentation-provided token | ||
| client.publishable_token = 'Tsk_341c973d296e4e18aa61dd63050ce235' |
There was a problem hiding this comment.
We default this to token and replace it everywhere for tests, as they are run from a recording. Don't leak your tokens!
There was a problem hiding this comment.
This particular endpoint is not available to free tier accounts (the plan I'm on!), so I had to update the endpoint to the sandbox, where of course, different keys are needed. the token in this code is copy/pasted from the iexcloud docs, so it's already publicly exposed!
There was a problem hiding this comment.
Is it that they have it in sandbox but not in production yet? In which case you can manually remove the sandbox part from tests and edit VCRs once you have a working recording.
| 'search', | ||
| fragment | ||
| ].compact.join('/'), options).map do |data| | ||
| # Per the IEX documentation, any type of Resource could be returned |
There was a problem hiding this comment.
Yes, please. And create a base resource for anything unsupported.
There was a problem hiding this comment.
fyi, they have not released this feature yet, the docs just mention that it is coming
There was a problem hiding this comment.
I don't see a problem supporting something in pre-release, but we have to say it in README and point to whatever IEX docs that say the same
|
The code here looks good. You still need to remove your actual secret token from everywhere! |
|
Also add a comment when this is ready to re-review, commits don't get flagged in notifications. |
|
Bump @pmn4, want to finish this? |
|
@dblock there are a few items here:
do these make sense? sorry for the confusion, and the delay! (tbh, I was only evaluating IEX when I authored this PR, and have since switched gears to another provider.) |
ok
you just don't want the real token in this PR because someone will steal it; once a recording was made you can just replace it with a placeholder |
I'll leave this open for someone/you to finish it. |
This PR adds the "Search" endpoint. Search doesn't quite fit the Resourceful pattern, so I put the tests in
client_spec.rb. Happy to move them if you'd prefer them to be in their own file (I just felt strange because there is no resource to use indescribe <Resource>).I also added a new Error class, and to allow for better rescuing, created an error superclass for the gem. Also happy to revert if it doesn't feel right.