Created
July 30, 2021 08:09
-
-
Save musketyr/24c5d05a9324af497fddc1bb65d53f27 to your computer and use it in GitHub Desktop.
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.agorapulse.dru.Dru | |
import com.agorapulse.gru.Gru | |
import com.agorapulse.gru.grails.Grails | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import grails.testing.gorm.DataTest | |
import grails.testing.web.controllers.ControllerUnitTest | |
import spock.lang.AutoCleanup | |
import spock.lang.Specification | |
class VehicleControllerSpec extends Specification implements ControllerUnitTest<VehicleController>, DataTest { | |
@AutoCleanup Dru dru = Dru.create { | |
include HelloDataSets.VEHICLES | |
} | |
@AutoCleanup Gru gru = Gru.create(Grails.create(this)).prepare { | |
include UrlMappings | |
} | |
@Override | |
Closure doWithSpring() { | |
return { | |
objectMapper(ObjectMapper) | |
} | |
} | |
void 'render with gru'() { | |
given: | |
dru.load() | |
controller.vehicleDataService = Mock(VehicleDataService) { | |
findById(1) >> dru.findByType(Vehicle) | |
} | |
expect: | |
gru.test { | |
get '/vehicle/1' | |
expect { | |
json 'vehicle.json' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment