-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
spock-specs/src/test/groovy/org/spockframework/smoke/ast/mock/MocksAstSpec.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.spockframework.smoke.ast.mock | ||
|
||
import org.spockframework.EmbeddedSpecification | ||
|
||
class MocksAstSpec extends EmbeddedSpecification { | ||
|
||
def "simple interaction"() { | ||
when: | ||
def result = compiler.transpileFeatureBody(""" | ||
given: | ||
List list = Mock() | ||
when: | ||
list.add(1) | ||
then: | ||
1 * list.add(1) | ||
""") | ||
then: | ||
result.source == '''\ | ||
@org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.WHEN, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.THEN, texts = [])], parameterNames = []) | ||
public void $spock_feature_0_0() { | ||
try { | ||
org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) | ||
java.util.List list = this.MockImpl('list', java.util.List) | ||
org.spockframework.runtime.SpockRuntime.callExitBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) | ||
this.getSpecificationContext().getMockController().enterScope() | ||
this.getSpecificationContext().getMockController().addInteraction(new org.spockframework.mock.runtime.InteractionBuilder(8, 5, '1 * list.add(1)').setFixedCount(1).addEqualTarget(list).addEqualMethodName('add').setArgListKind(true, false).addEqualArg(1).build()) | ||
org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) | ||
list.add(1) | ||
org.spockframework.runtime.SpockRuntime.callExitBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) | ||
this.getSpecificationContext().getMockController().leaveScope() | ||
org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) | ||
org.spockframework.runtime.SpockRuntime.callExitBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) | ||
this.getSpecificationContext().getMockController().leaveScope() | ||
} | ||
finally { | ||
org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} | ||
}''' | ||
} | ||
} |