-
Notifications
You must be signed in to change notification settings - Fork 47
Layla - Edges - Muncher #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
| Rails.application.routes.draw do | ||
| root 'main#index' | ||
| resources :recipes, only: [:index] | ||
| resource :recipe, only: [:show] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not resources :recipes, only: [:index, :show]?
| parsed_recipe = {} | ||
|
|
||
| parsed_recipe[:name] = recipe['label'] | ||
| parsed_recipe[:image_url] = recipe['image'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of storing this data in a hash, you should define a Recipe class. That would allow your views to treat it the same as an ActiveRecord model.
|
|
||
| response = EdamamApiWrapper.search_recipes(params) | ||
| response = EdamamApiWrapper.parse_api_response(response) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code would be a little cleaner if, instead of having to call two methods in sequence, you had one method that did all the work.
| def self.parse_recipe(recipe) | ||
| recipe = recipe[0] if recipe.is_a?(Array) | ||
| parsed_recipe = {} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method be private?
|
|
||
| describe "search" do | ||
|
|
||
| it "can get search page" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the search turns up no results?
| it "can get a single recipe" do | ||
| VCR.use_cassette("get_single_recipe") do | ||
| recipe = { | ||
| :uri => "http://www.edamam.com/ontologies/edamam.owl#recipe_6245fdcbb8c11fc1784df27c4d3426c5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be under the search describe block.
Missing case: what if the URI is bad?
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions
lib? How would your project change if you needed to interact with more than one API (aka more than just the Edamam API)?