Check out this SlideShare Presentation:
Git, Beginner to Advanced Survey
View more presentations from Rafal Rusin.
Check out this SlideShare Presentation:
Git, Beginner to Advanced Survey
import spock.lang.Specification
class OfferFacadeSpec extends Specification {
OfferFacade facade = new OfferFacade()
def setup() {
GroovyMock(Project, global: true)
}
def 'delegates an add offer call to the domain with proper params'() {
given:
Map params = [projId: projectId, name: offerName]
when:
Offer returnedOffer = facade.add(params)
then:
1 * Project.addOffer(projectId, _) >> { projId, offer -> offer }
returnedOffer.name == params.name
where:
projectId | offerName
1 | 'an Offer'
15 | 'whasup!?'
123 | 'doskonała oferta - kup teraz!'
}
}So we test a facade responsible for handling "add offer to the project" call triggered somewhere in a GUI.import spock.lang.Specification
class OfferFacadeSpec extends Specification {
OfferFacade facade = new OfferFacade()
def setup() {
GroovyMock(Project, global: true)
}
def 'delegates an add offer call to the domain with proper params'() {
given:
Map params = [projId: projectId, name: offerName]
when:
Offer returnedOffer = facade.add(params)
then:
1 * Project.addOffer(projectId, _) >> { projId, offer -> offer }
returnedOffer.name == params.name
where:
projectId | offerName
1 | 'an Offer'
15 | 'whasup!?'
123 | 'doskonała oferta - kup teraz!'
}
}So we test a facade responsible for handling "add offer to the project" call triggered somewhere in a GUI.