Skip to content

Commit

Permalink
fix: Lambda based DSL stringType method did not match the old DSL #1850
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Feb 11, 2025
1 parent 287b16c commit 5dba442
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ public LambdaDslObject stringType(final String name) {
return this;
}

/**
* Attribute that can be any string
* @param name attribute name
* @param examples example values to use for generated bodies
*/
public LambdaDslObject stringType(final String name, final String... examples) {
object.stringType(name, examples);
return this;
}

/**
* Attributes that can be any string
*
* @param names attribute names
*/
public LambdaDslObject stringType(final String... names) {
public LambdaDslObject stringTypes(final String... names) {
object.stringTypes(names);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,21 @@ class LambdaDslJsonBodySpec extends Specification {
])
]
}

@Issue('#1850')
def 'multiple example values'() {
when:
def oldDsl = new PactDslJsonBody()
.minArrayLike('features', 1, 2)
.stringType('name', 'FEATURE', 'FEATURE_2')
.close()
def newDsl = newJsonBody { o ->
o.minArrayLike('features', 1, 2) { feature ->
feature.stringType('name', 'FEATURE', 'FEATURE_2')
}
}.build()

then:
oldDsl.body.toString() == newDsl.body.toString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void testStringTypes() {
final PactDslJsonBody actualPactDsl = new PactDslJsonBody();
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringType(new String[]{"foo", "bar"});
.stringTypes(new String[]{"foo", "bar"});
actualPactDsl.close();

String actualJson = actualPactDsl.getBody().toString();
Expand Down

0 comments on commit 5dba442

Please sign in to comment.