I have a EncouragementService.groovy
with following method
class EncouragementService {
def stripePaymentService
def encourageUsers(List&l
Use the build-test-data plugin to build the users.
@TestFor(EncouragementService)
@Build(User)
class EncouragementServiceSpec extends Specification {
def "encourage users does x"() {
given:
def users = createUsers();
when:
service.encourageUsers(users)
then:
// assert something
}
def createUsers(){
[User.build(), User.build(), User.build()]
}
}
I've also made a couple of changes to the code to make it a proper spock specification. Your test has to extend Specification and you might want to familiarize yourself with Spock's keywords.