I have test cases built using spock and groovy in my java application. Is it possible to add spring rest docs to this project without using mock mvc or restassured
Here is a snipped of my project
import groovyx.net.http.RESTClient;
import spock.lang.Specification;
class FindIdeasSpec extends Specification{
def host ="http://www.localhost.com:8080/v1/"
def path = "communities/"
def client = new RESTClient(host)
def id = 1
def "verify the links"() {
when: "request ideas list"
def response = client.get(path: path + id + '/ideas')
then: "returns parent and self link"
with(response) {
status == 200
data.links.rel == ['self']
data.links.href[0] == host + path + id + '/ideas'
}
}
You can use Spring REST Docs with Spock, but you'll have to use either Mock MVC or REST Assured to test and document your RESTful service as those are the two testing frameworks that REST Docs supports.
From REST Docs' perspective, using Spock is very similar to using JUnit as you continue to use the JUnitRestDocumentation rule. You can see this in action in ApiDocumentationSpec
from REST Docs' Grails sample. The sample shows how to test and documents a service implemented with Grails using REST Docs and REST Assured.