Skip to content

Commit 72c3d4a

Browse files
committed
Update docs, make stringInDoubleQuotes require at least one character between quotes.
1 parent afed98d commit 72c3d4a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

docs/support_files/api_reference.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,35 @@ The function passed to `defineSupportCode` is called with an object as the first
66

77
---
88

9-
#### `addTransform({captureGroupRegexps, typeName, transformer})`
9+
#### `defineParameterType({regexp, typeName, transformer})`
1010

1111
Add a new transform to convert a capture group into something else.
1212

13-
* `captureGroupRegexps`: An array of regular expressions to apply the transformer to
14-
* `transformer`: A function which transforms the captured group from a string into what is passed to the step definition
13+
* `regexp`: A regular expression (or array of regular expressions) that match the parameter
1514
* `typeName`: string used to refer to this type in cucumber expressions
15+
* `transformer`: An optional function which transforms the captured argument from a string into what is passed to the step definition.
16+
If no transform function is specified, the captured argument is left as a string.
1617

1718
The built in transforms are:
1819

1920
```javascript
2021
// Float
2122
{
22-
captureGroupRegexps: ['-?\\d*\\.?\\d+'],
23+
regexp: /-?\d*\.?\d+/,
2324
transformer: parseFloat,
2425
typeName: 'float'
2526
}
2627

27-
// Int
28+
// Integer
2829
{
29-
captureGroupRegexps: ['-?\\d+'],
30+
regexp: /-?\d+/,
3031
transformer: parseInt,
3132
typeName: 'int'
3233
}
3334

3435
// String in double quotes
3536
{
36-
captureGroupRegexps: ['"[^"]*"'],
37+
regexp: /"[^"]+"/,
3738
transformer: JSON.parse,
3839
typeName: 'stringInDoubleQuotes'
3940
}

src/support_code_library/parameter_type_registry_builder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ function build() {
44
const parameterTypeRegistry = new ParameterTypeRegistry()
55
const stringInDoubleQuotesParameterType = new ParameterType(
66
'stringInDoubleQuotes',
7-
function() {},
8-
'"[^"]*"',
7+
null,
8+
/"[^"]+"/,
99
JSON.parse
1010
)
1111
parameterTypeRegistry.defineParameterType(stringInDoubleQuotesParameterType)

0 commit comments

Comments
 (0)