summaryrefslogtreecommitdiff
path: root/reuse/features
diff options
context:
space:
mode:
Diffstat (limited to 'reuse/features')
-rw-r--r--reuse/features/reusable.feature10
-rw-r--r--reuse/features/steps/lodash.js15
-rw-r--r--reuse/features/steps/ramda.js15
-rw-r--r--reuse/features/steps/reusable.js6
-rw-r--r--reuse/features/support/name-world.js5
5 files changed, 46 insertions, 5 deletions
diff --git a/reuse/features/reusable.feature b/reuse/features/reusable.feature
index 98136ff..20c878d 100644
--- a/reuse/features/reusable.feature
+++ b/reuse/features/reusable.feature
@@ -3,3 +3,13 @@ Feature:
Given a person with name
And a person named Jack
Then the same function is called for two distinct step definitions
+
+ Scenario:
+ Given a person with a first name
+ And a person with the first name Jack
+ Then the first names are collected by the same function
+
+ Scenario:
+ Given a person with a last name
+ And a person with the last name Doe
+ Then the last names are collected by the same function
diff --git a/reuse/features/steps/lodash.js b/reuse/features/steps/lodash.js
new file mode 100644
index 0000000..63092e1
--- /dev/null
+++ b/reuse/features/steps/lodash.js
@@ -0,0 +1,15 @@
+import { Before, Given, Then } from 'cucumber'
+import { expect } from 'chai'
+import _ from 'lodash'
+
+function step (name) {
+ this.names.push(name)
+}
+
+Given('a person with a first name', _.partial(step, 'John'))
+Given('a person with the first name {word}', step)
+
+Then('the first names are collected by the same function', function () {
+ expect(this.names).to.have.lengthOf(2)
+ expect(this.names).to.include.members(['John', 'Jack'])
+})
diff --git a/reuse/features/steps/ramda.js b/reuse/features/steps/ramda.js
new file mode 100644
index 0000000..b7914b8
--- /dev/null
+++ b/reuse/features/steps/ramda.js
@@ -0,0 +1,15 @@
+import { Before, Given, Then } from 'cucumber'
+import { expect } from 'chai'
+import R from 'ramda'
+
+function step (name) {
+ this.names.push(name)
+}
+
+Given('a person with a last name', R.partial(step, ['Junior']))
+Given('a person with the last name {word}', R.partial(step, []))
+
+Then('the last names are collected by the same function', function () {
+ expect(this.names).to.have.lengthOf(2)
+ expect(this.names).to.include.members(['Junior', 'Doe'])
+})
diff --git a/reuse/features/steps/reusable.js b/reuse/features/steps/reusable.js
index 07ac8c5..674756f 100644
--- a/reuse/features/steps/reusable.js
+++ b/reuse/features/steps/reusable.js
@@ -1,10 +1,6 @@
import { Before, Given, Then } from 'cucumber'
import { expect } from 'chai'
-Before(function () {
- this.names = []
-})
-
function step (name) {
this.names.push(name)
}
@@ -13,7 +9,7 @@ function decorator (f, ...args) {
if (args.length > 0) {
return function () {
f.call(this, args[0])
- }
+ }
} else {
return f
}
diff --git a/reuse/features/support/name-world.js b/reuse/features/support/name-world.js
new file mode 100644
index 0000000..151d36b
--- /dev/null
+++ b/reuse/features/support/name-world.js
@@ -0,0 +1,5 @@
+import { setWorldConstructor } from 'cucumber'
+
+setWorldConstructor(function () {
+ this.names = []
+})