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
dependencies { | |
runtime 'com.github.groovy-wslite:groovy-wslite:0.8.0' | |
} | |
plugins { | |
// plugins for the build system only | |
build ":tomcat:7.0.50" | |
// plugins for the compile step | |
compile ":scaffolding:2.0.1" |
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
class GameSpec extends Specification { | |
@Shared | |
RESTClient restClient = new RESTClient("http://localhost:8080/restful-gr8conf-2014") | |
def "it returns a list of games in JSON"() { | |
when: | |
Response response = restClient.get(path: "/games", accept: ContentType.JSON) | |
then: |
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
def castleBuilder = new Game(name: 'Castle Builder').save() | |
def amazingCircus = new Game(name: 'The Amazing Circus').save() | |
def pokerDrop = new Game(name: 'Poker Drop Riches').save() | |
def petsPayDay = new Game(name: "Pet's Pay Day").save() | |
def grandBlackjack = new Game(name: 'Grand Blackjack').save() |
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
def "it creates games"() { | |
when: | |
Response response = restClient.post(path: "/games") { | |
json name:"New game" | |
} | |
then: | |
response.statusCode == 201 | |
response.headers['Location'] | |
} |
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
import com.odobo.gr8conf.Category | |
import com.odobo.gr8conf.Game | |
class BootStrap { | |
def init = { servletContext -> | |
def slot = new Category(name: 'Slot').save() | |
def instantWin = new Category(name: 'Instant Win').save() | |
def card = new Category(name: 'Card').save() |
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
"/categories"(resources:"category") | |
"/games"(resources: "game") { | |
"/categories"(resources:"category") | |
} |
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
def "it returns just the categories of a game when is a nested resource"() { | |
when: | |
Response response = restClient.get(path: "/games/5/categories", accept: ContentType.JSON) | |
println response.json | |
then: | |
response.json.size() == 2 | |
} |
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 grails.rest.RestfulController | |
import grails.transaction.Transactional | |
@Transactional(readOnly = true) | |
class CategoryController extends RestfulController { | |
static responseFormats = ['json', 'xml'] |
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 grails.rest.RestfulController | |
import grails.transaction.Transactional | |
@Transactional(readOnly = true) | |
class CategoryController extends RestfulController { | |
static responseFormats = ['json', 'xml'] |
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.Response | |
class CategorySpec extends Specification { |
OlderNewer