Created
June 2, 2014 02:14
-
-
Save alvarosanchez/8276d6e5e4b7614b3289 to your computer and use it in GitHub Desktop.
CategorySpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.odobo.gr8conf | |
import spock.lang.Shared | |
import spock.lang.Specification | |
import wslite.rest.ContentType | |
import wslite.rest.RESTClient | |
import wslite.rest.RESTClientException | |
import wslite.rest.Response | |
/** | |
* Created by mariscal on 01/06/14. | |
*/ | |
class CategorySpec extends Specification { | |
@Shared | |
RESTClient restClient = new RESTClient("http://localhost:8080/restful-gr8conf-2014") | |
def "it returns a list of categories in JSON"() { | |
when: | |
Response response = restClient.get(path: "/categories", accept: ContentType.JSON) | |
then: | |
response.json | |
response.contentType == 'application/json' | |
} | |
def "it can't create new categories"() { | |
when: | |
Response response = restClient.post(path: "/categories") { | |
json name:"New game" | |
} | |
then: | |
RESTClientException e = thrown(RESTClientException) | |
e.response.statusCode == 405 | |
} | |
def "it can't modify existing categories"() { | |
when: | |
restClient.put(path: "/categories/1") { | |
json name:"New category name" | |
} | |
then: | |
RESTClientException e = thrown(RESTClientException) | |
e.response.statusCode == 405 | |
} | |
def "it can't remove categories"() { | |
when: | |
restClient.delete(path: "/categories/1") | |
then: | |
RESTClientException e = thrown(RESTClientException) | |
e.response.statusCode == 405 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment