Add example with non-standard formatters
This commit is contained in:
16
formatter/features/formatter.feature
Normal file
16
formatter/features/formatter.feature
Normal file
@ -0,0 +1,16 @@
|
||||
Feature:
|
||||
Scenario:
|
||||
Given the numbers:
|
||||
| Summand | Summand |
|
||||
| 1 | 1 |
|
||||
When I sum them
|
||||
Then I get 2
|
||||
|
||||
Given a list of proper names:
|
||||
| Jakob |
|
||||
| Ludwig |
|
||||
| Felix |
|
||||
| Mendelssohn |
|
||||
| Bartholdy |
|
||||
When I concatenate them together
|
||||
Then the name is "Jakob Ludwig Felix Mendelssohn Bartholdy"
|
29
formatter/features/steps/formatter.js
Normal file
29
formatter/features/steps/formatter.js
Normal file
@ -0,0 +1,29 @@
|
||||
const { Given, When, Then } = require('cucumber')
|
||||
const assert = require('assert')
|
||||
|
||||
Given('the numbers:', function (dataTable) {
|
||||
this.numbers = dataTable.rows()[0]
|
||||
})
|
||||
|
||||
When('I sum them', function () {
|
||||
this.sum = this.numbers
|
||||
.map(x => parseInt(x))
|
||||
.reduce((x, acc) => acc + x, 0)
|
||||
})
|
||||
|
||||
Then('I get {int}', function (int) {
|
||||
assert.equal(this.sum, int)
|
||||
})
|
||||
|
||||
Given('a list of proper names:', function (dataTable) {
|
||||
this.names = dataTable.raw()
|
||||
.map(x => x[0])
|
||||
})
|
||||
|
||||
When('I concatenate them together', function () {
|
||||
this.name = this.names.join(' ')
|
||||
})
|
||||
|
||||
Then('the name is {string}', function (string) {
|
||||
assert.equal(this.name, string)
|
||||
})
|
Reference in New Issue
Block a user