-
Notifications
You must be signed in to change notification settings - Fork 44
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
API Muncher - Angela - Octos #31
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
|
||
get '/recipes', to: 'recipes#index', as: 'recipes' | ||
|
||
get '/recipes/:label', to: 'recipes#show', as: "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.
Could you use resources :recipes, only: [:index, :show]
here?
|
||
if uri.nil? || uri.empty? | ||
raise ArgumentError.new("Need a recipe uri pls") | ||
end |
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.
Good work validating only things that will break your app if they're not there.
def self.raise_on_error(response) | ||
unless response["count"] | ||
raise RecipeError.new(response["error"]) | ||
end |
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 method is never called! Please don't copy-paste code without understanding how it fits together.
# ALWAYS CHECK YOUR ERROR CODES | ||
# unless response.success? | ||
# raise StandardError.new(response["error"]) | ||
# end |
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.
# ALWAYS CHECK YOUR ERROR CODES
ಠ_ಠ
|
||
it "displays the recipe page for the selected recipe" do | ||
VCR.use_cassette("recipe") do | ||
uri = "http://www.edamam.com/ontologies/edamam.owl#recipe_e427aa9f6e7a96ecadbf994d9f75fd14" |
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 about for a bad recipe uri?
describe 'index' do | ||
it "returns a list of search recipes results" do | ||
query = "chicken" | ||
VCR.use_cassette("recipes") 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.
There are some interesting cases you're not covering here:
- What happens if no search term is provided?
- What if there are no paging parameters provided?
- What if the paging parameters are invalid (negative number, etc)?
- What if the paging parameters take you past the end of the available search results?
|
||
it "can't give a list of recipes" do | ||
VCR.use_cassette("recipes") do | ||
recipe = RecipeApiWrapper.list_recipes("jdns2n") |
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.
You need some tests for show
here! I would be interested in at least what happens when for a good vs bad uri.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions