We Eatt


API Documentation

Api Recipe Search

Feature: /api/v1/recipes

	As an API User
	I want to search for recipes
	So that I can find cool stuff to cook

	Background: 
		Given I am a We Eatt chef
		And my "Content-Type" header is set to "application/json
		And my "Accept" header is set to "application/json"
		And my application api-key is set in the "x-api-key" header"
		And a recipe exists with "sweet" in the "name"
		And a recipe exists with "sweet" in the "description"
		And a recipe exists with "sweet" in the "ingredients"

	Scenario: Search with Results
		When I send a GET request to "/api/v1/recipes?qs=sweet&auth_token=[@chef.auth_token]"
		Then the response status should be "200"
		And the response should be a JSON Array with 3 "Recipe" objects:
		"""
		{
				"query": "sweet",
				"total_results": 35,
				"per_page": 30,
				"total_pages": 2,
				"page": 1,
				"results": [
						{
								"id": 656,
								"permalink": "crock-pot-sweet-and-sour",
								"name": "Crock Pot Sweet and Sour ",
								"ingredients": "1 pound chicken (or other meat)\r\n1/2 green pepper\r\n1/2 red pepper\r\n1 cup fresh broccoli\r\n1/2 red onion\r\n1/4 teaspoon onion powder\r\n1/4 teaspoon garlic powder\r\n1 can pineapple tidbits (8 ounce)\r\n1 tablespoon brown sugar\r\n1/2 bottle sweet and sour sauce\r\n1 cup prepared rice",
								"instructions": "Cut meat into bite sized pieces.  Place in crock pot with onion powder and garlic powder.  Stir.   Drain pineapple, saving juice.   Add brown sugar, sweet and sour sauce, pineapple tidbits and 1/2 of the pineapple juice to crock pot.  Cook on high for a few hours stirring occasionally.   Chop vegetables into large pieces and add to crock pot with remaining pineapple juice, cook for 1/2 hour longer.  Serve over rice.",
								"description": "Super easy knock off of Chinese take out!",
								"chef": {
										"id": 604,
										"name": "Jen Kahler",
										"login": "jkahler",
										"large_avatar_path": "/system/avatars/149/large/200707-208125_0379_900.jpg?1299698086",
										"thumbnail_avatar_path": "/system/avatars/149/thumb/200707-208125_0379_900.jpg?1299698086"
								},
								"images": [
										{
												"id": 653,
												"large_image_path": "/photos/large/missing.png",
												"thumbnail_path": "/photos/thumbnail/missing.png"
										}
								],
								"videos": [
										
								]
						},
						{
								"id": 55,
								"permalink": "date-balls",
								"name": "Date Balls",
								"ingredients": "2 eggs\r\n1 cup sugar\r\n1 1/2 cups chopped dates\r\nPinch of salt\r\n2 tablespoons unsalted butter\r\n1 teaspoon vanilla\r\n2 cups Rice Krispies\r\n1 to 1 1/2 cups chopped nuts\r\nCoconut",
								"instructions": "Cook first five ingredients until thick.\r\nAdd vanilla, Rice Krispies and nuts.\r\nCool.\r\nRoll into balls and roll balls in coconut.\r\n\r\nMakes 2 dozen balls.",
								"description": "Old fashioned sweet.",
								"chef": {
										"id": 25,
										"name": "Jerry Kirkpatrick",
										"login": "mrstardad",
										"large_avatar_path": null,
										"thumbnail_avatar_path": null
								},
								"images": [
										
								],
								"videos": [
										
								]
						},
						{
								"id": 280,
								"permalink": "barbecue-sauce",
								"name": "Barbecue Sauce",
								"ingredients": "1/2 c. Original Molasses, unsulphured\r\n1/2 c. granulated sugar\r\n1/2 c. ketchup\r\n4 T. Worcestershire sauce\r\n1 t. hickory smoke liquid\r\n1 T. onion powder\r\n1 T. garlic powder\r\n1/8 t. chipotle pepper\r\n\r\n",
								"instructions": "Mix all ingredients together.",
								"description": "Sweet and spicy",
								"chef": {
										"id": 465,
										"name": "Debra Underwood",
										"login": "DebraK",
										"large_avatar_path": "/system/avatars/103/large/Debra_s_pictures_304.jpg?1299698077",
										"thumbnail_avatar_path": "/system/avatars/103/thumb/Debra_s_pictures_304.jpg?1299698077"
								},
								"images": [
										
								],
								"videos": [
                    {
                        "video": {
                            "url": "http://www.youtube.com/watch?v=OevHygNPp_w"
                        }
                    }
								]
						}
				]
		}
		"""		
	Scenario: Search with No Results Found
		When I send a GET request to "/api/v1/recipes?qs=weird+query+no+results&auth_token=[@chef.auth_token]"
		Then the response status should be "200"
		And the response should be a JSON Array with 0 "Recipe" objects:
		"""
		{[]}
		"""

	Scenario: Search with an expired or invalid Auth Token
		Given No chef exists with auth_token "23456325634"
		When I send a GET request to "/api/v1/recipes?qs=sweet&auth_token=23456325634"
		Then the response status should be "401"