3 ms·
Some quick feedback on this: * Consider extracting things like the headers hash to a method. * For things like "search_ingredients_by_name", you'll want to ei
by al2o3cr 9y ago
Some quick feedback on this:
* Consider extracting things like the headers hash to a method.
* For things like "search_ingredients_by_name", you'll want to either properly escape the query parameter before interpolating it or use the HTTParty API that passes query parameters separately.
* Review when to use an instance variable vs. when to use a local variable. Code like that in "get_pairings_for_ingredient" is going to fail in unexpected ways when running in a threaded server - two simultaneous requests could be manipulating "@pairings_array" simultaneously.
* Your mock response for "pairings" contains data that the documentation claims isn't there - in particular, the "name" field. The API docs suggest that all you get in that part of the payload is id & href.
* Related: your mock responses don't specify a "Content-Type" so HTTParty doesn't know to automatically parse the body as JSON. Live responses will set this header.
* Consider returning objects rather than primitives. Magic index values - like "id" and "name" - are a sign you probably have structured data.
* Not sure if it's a convention or enforced someplace, but the usual convention for naming ENV vars is ALL_CAPS_UNDERSCORED.