@@ -30,7 +30,8 @@ class NodeVisitorStubTest extends Specification {
3030
3131 }
3232
33- def " values nodes call visitValue by default" () {
33+ @Unroll
34+ def " #visitMethod call visitValue by default" () {
3435 given :
3536 NodeVisitorStub nodeVisitorStub = Spy (NodeVisitorStub , constructorArgs : [])
3637 TraverserContext context = Mock (TraverserContext )
@@ -54,38 +55,25 @@ class NodeVisitorStubTest extends Specification {
5455 new StringValue () | ' visitStringValue'
5556 }
5657
57- def " definitions call visitDefinition by default" () {
58+ @Unroll
59+ def " #visitMethod call visitDefinition by default" () {
5860 given :
5961 NodeVisitorStub nodeVisitorStub = Spy (NodeVisitorStub , constructorArgs : [])
60- OperationDefinition operationDefinition = new OperationDefinition ()
61- FragmentDefinition fragmentDefinition = new FragmentDefinition ()
62- DirectiveDefinition directiveDefinition = new DirectiveDefinition (" " )
63- SchemaDefinition schemaDefinition = new SchemaDefinition ()
6462 TraverserContext context = Mock (TraverserContext )
6563
6664 when :
67- def control = nodeVisitorStub. visitOperationDefinition(operationDefinition, context)
68- then :
69- 1 * nodeVisitorStub. visitDefinition(operationDefinition, context) >> TraversalControl . QUIT
70- control == TraversalControl . QUIT
71-
72- when :
73- control = nodeVisitorStub. visitFragmentDefinition(fragmentDefinition, context)
65+ def control = nodeVisitorStub. " $visitMethod " (node, context)
7466 then :
75- 1 * nodeVisitorStub. visitDefinition(fragmentDefinition , context) >> TraversalControl . QUIT
67+ 1 * nodeVisitorStub. visitDefinition(node , context) >> TraversalControl . QUIT
7668 control == TraversalControl . QUIT
7769
78- when :
79- control = nodeVisitorStub. visitDirectiveDefinition(directiveDefinition, context)
80- then :
81- 1 * nodeVisitorStub. visitDefinition(directiveDefinition, context) >> TraversalControl . QUIT
82- control == TraversalControl . QUIT
8370
84- when :
85- control = nodeVisitorStub. visitSchemaDefinition(schemaDefinition, context)
86- then :
87- 1 * nodeVisitorStub. visitDefinition(schemaDefinition, context) >> TraversalControl . QUIT
88- control == TraversalControl . QUIT
71+ where :
72+ node | visitMethod
73+ new OperationDefinition () | ' visitOperationDefinition'
74+ new FragmentDefinition () | ' visitFragmentDefinition'
75+ new DirectiveDefinition (" " ) | ' visitDirectiveDefinition'
76+ new SchemaDefinition () | ' visitSchemaDefinition'
8977 }
9078
9179 def " type definitions call visitTypeDefinition by default" () {
0 commit comments