Last active
January 22, 2020 20:22
-
-
Save kimberleehowley/18ad2de30fa070a1ff40126206835b70 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
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