Skip to content

Commit 96e6e25

Browse files
committed
Update parameter scenarios to use new API. Remove redundant scenarios.
1 parent 513dfb1 commit 96e6e25

File tree

2 files changed

+44
-98
lines changed

2 files changed

+44
-98
lines changed

features/custom_parameter.feature

-74
This file was deleted.

features/parameter_transforms.feature

+44-24
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,116 @@
11
Feature: Parameter transforms
22

3+
Users can register their own parameters to be used in Cucumber expressions.
4+
Custom parameters can be used to match certain patterns, and optionally to
5+
transform the matched value into a custom type.
6+
37
Background:
4-
Given a file named "features/passing_steps.feature" with:
8+
Given a file named "features/particular_steps.feature" with:
59
"""
610
Feature: a feature
711
Scenario: a scenario
8-
Given a passing step
12+
Given a particular step
913
"""
1014
Given a file named "features/step_definitions/my_steps.js" with:
1115
"""
1216
import assert from 'assert'
1317
import {defineSupportCode} from 'cucumber'
1418
1519
defineSupportCode(({Given}) => {
16-
Given('a {status} step', function(status) {
17-
assert.equal(status, 'PASSING')
20+
Given('a {param} step', function(param) {
21+
assert.equal(param, 'PARTICULAR')
1822
})
1923
})
2024
"""
2125

2226
Scenario: sync transform (success)
27+
Given a file named "features/support/transforms.js" with:
28+
"""
29+
import {defineSupportCode} from 'cucumber'
30+
31+
defineSupportCode(({addParameter}) => {
32+
addParameter({
33+
captureGroupRegexps: /particular/,
34+
transformer: s => s.toUpperCase(),
35+
typeName: 'param'
36+
})
37+
})
38+
"""
39+
When I run cucumber.js
40+
Then the step "a particular step" has status "passed"
41+
42+
Scenario: sync transform (success) using deprecated addTransform API
2343
Given a file named "features/support/transforms.js" with:
2444
"""
2545
import {defineSupportCode} from 'cucumber'
2646
2747
defineSupportCode(({addTransform}) => {
2848
addTransform({
29-
captureGroupRegexps: ['passing'],
49+
captureGroupRegexps: /particular/,
3050
transformer: s => s.toUpperCase(),
31-
typeName: 'status'
51+
typeName: 'param'
3252
})
3353
})
3454
"""
3555
When I run cucumber.js
36-
Then the step "a passing step" has status "passed"
56+
Then the step "a particular step" has status "passed"
3757

3858
Scenario: sync transform (error)
3959
Given a file named "features/support/transforms.js" with:
4060
"""
4161
import {defineSupportCode} from 'cucumber'
4262
43-
defineSupportCode(({addTransform}) => {
44-
addTransform({
45-
captureGroupRegexps: ['passing'],
63+
defineSupportCode(({addParameter}) => {
64+
addParameter({
65+
captureGroupRegexps: /particular/,
4666
transformer: s => {
4767
throw new Error('transform error')
4868
},
49-
typeName: 'status'
69+
typeName: 'param'
5070
})
5171
})
5272
"""
5373
When I run cucumber.js
5474
Then it fails
55-
And the step "a passing step" failed with:
75+
And the step "a particular step" failed with:
5676
"""
5777
transform error
5878
"""
5979

6080
Scenario: async transform (success)
61-
Given a file named "features/step_definitions/passing_steps.js" with:
81+
Given a file named "features/step_definitions/particular_steps.js" with:
6282
"""
6383
import {defineSupportCode} from 'cucumber'
6484
import Promise from 'bluebird'
6585
66-
defineSupportCode(({addTransform}) => {
67-
addTransform({
68-
captureGroupRegexps: ['passing'],
86+
defineSupportCode(({addParameter}) => {
87+
addParameter({
88+
captureGroupRegexps: /particular/,
6989
transformer: s => Promise.resolve(s.toUpperCase()),
70-
typeName: 'status'
90+
typeName: 'param'
7191
})
7292
})
7393
"""
7494
When I run cucumber.js
75-
Then the step "a passing step" has status "passed"
95+
Then the step "a particular step" has status "passed"
7696

7797
Scenario: async transform (error)
78-
Given a file named "features/step_definitions/passing_steps.js" with:
98+
Given a file named "features/step_definitions/particular_steps.js" with:
7999
"""
80100
import {defineSupportCode} from 'cucumber'
81101
import Promise from 'bluebird'
82102
83-
defineSupportCode(({addTransform}) => {
84-
addTransform({
85-
captureGroupRegexps: ['passing'],
103+
defineSupportCode(({addParameter}) => {
104+
addParameter({
105+
captureGroupRegexps: /particular/,
86106
transformer: s => Promise.reject(new Error('transform error')),
87-
typeName: 'status'
107+
typeName: 'param'
88108
})
89109
})
90110
"""
91111
When I run cucumber.js
92112
Then it fails
93-
And the step "a passing step" failed with:
113+
And the step "a particular step" failed with:
94114
"""
95115
transform error
96116
"""

0 commit comments

Comments
 (0)