POST, GET, UPDATE, DELETE Cars:

POST car request:

should return success message
server.post("/api/cars")
.send(valid_car_specs)
		    .expect("Content-type",/json/)
		    .expect(200) // THis is HTTP response
		    .end(function(err,res){
		     	res.status.should.equal(200);
		     	res.body.message.should.equal("car added successfully"); 
		     	done();
		    });

POST car request:

should return error message
server.post("/api/cars")
.send(invalid_car_specs)
		    .expect("Content-type",/json/)
		    .expect(200) // THis is HTTP response
		    .end(function(err,res){
		     	res.status.should.equal(200);
		     	res.body.error.message.should.equal("car validation failed");  
		     	done();
		    });

GET all cars request:

should return success message
server.get("/api/cars")
		    .expect("Content-type",/json/)
		    .expect(200) // THis is HTTP response
		    .end(function(err,res){
		    	
		    	// status code should be 200
		     	res.status.should.equal(200);
		     	
		     	// type of results should be of type array
		     	(Array.isArray(res.body.results)).should.be.true(); 

		     	// all elements of array should have 3 properties: model, make and year per the spec
	     		for (var i = 0; i < res.body.results.length; i++){
	     			(Object.keys(res.body.results[i]).length === car_properties.length).should.be.true();
	     			for (var j = 0; j < car_properties.length; j++){
	     				(res.body.results[i].hasOwnProperty(car_properties[j])).should.be.true(); 
	     			}
	     		}
     	 
		     	done();
		    });

POST, GET, UPDATE, DELETE Ratings:

GET all ratings request:

should return success message
server.get("/api/ratings")
		    .expect("Content-type",/json/)
		    .expect(200) // THis is HTTP response
		    .end(function(err,res){

		    	// status code should be 200
		     	res.status.should.equal(200);
		     	
		     	// type of results should be of type array
		     	(Array.isArray(res.body.results)).should.be.true(); 

		     	// all elements of array should have all ratings properties per the spec
	     		for (var i = 0; i < res.body.results.length; i++){
	     			(Object.keys(res.body.results[i]).length === rating_properties.length).should.be.true();
	     			for (var j = 0; j < rating_properties.length; j++){
	     				(res.body.results[i].hasOwnProperty(rating_properties[j])).should.be.true(); 
	     			}
	     		}
     	 
		     	done();
		    });