Skip to content

Instantly share code, notes, and snippets.

@kimberleehowley
Last active January 22, 2020 20:22
Show Gist options
  • Save kimberleehowley/18ad2de30fa070a1ff40126206835b70 to your computer and use it in GitHub Desktop.
Save kimberleehowley/18ad2de30fa070a1ff40126206835b70 to your computer and use it in GitHub Desktop.
package com.testguide
import grails.testing.gorm.DomainUnitTest
import org.springframework.validation.FieldError
import spock.lang.Specification
import static com.testguide.StringUtil.newUuid
import static com.testguide.test.UnitTestDomainFactory.createDomain
class CampaignSpec extends Specification implements DomainUnitTest<Campaign> {
void "invalid creation of a campaign"() {
given: "a user"
def user = createDomain(User)
and: "a survey"
def survey = createDomain(Survey, [user: user])
when: "the domain has lacks the required properties"
domain.survey = survey
domain.uuid = newUuid()
then: "the campaign is invalid"
!domain.validate()
and:
domain.errors.fieldErrors.size() > 0
}
void "valid creation of a campaign"() {
given: "a user"
def user = createDomain(User)
and: "a survey"
def survey = createDomain(Survey, [user: user])
when: "the domain has the required properties"
domain.user = user
domain.survey = survey
domain.uuid = newUuid()
then: "the campaign is valid"
domain.validate()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment