reuse: Apply function with Ramda and Lodash
This commit is contained in:
		| @@ -3,3 +3,13 @@ Feature: | |||||||
| 		Given a person with name | 		Given a person with name | ||||||
| 		And a person named Jack | 		And a person named Jack | ||||||
| 		Then the same function is called for two distinct step definitions | 		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 | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								reuse/features/steps/lodash.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reuse/features/steps/lodash.js
									
									
									
									
									
										Normal file
									
								
							| @@ -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']) | ||||||
|  | }) | ||||||
							
								
								
									
										15
									
								
								reuse/features/steps/ramda.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reuse/features/steps/ramda.js
									
									
									
									
									
										Normal file
									
								
							| @@ -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']) | ||||||
|  | }) | ||||||
| @@ -1,10 +1,6 @@ | |||||||
| import { Before, Given, Then } from 'cucumber' | import { Before, Given, Then } from 'cucumber' | ||||||
| import { expect } from 'chai' | import { expect } from 'chai' | ||||||
|  |  | ||||||
| Before(function () { |  | ||||||
|   this.names = [] |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| function step (name) { | function step (name) { | ||||||
|   this.names.push(name) |   this.names.push(name) | ||||||
| } | } | ||||||
| @@ -13,7 +9,7 @@ function decorator (f, ...args) { | |||||||
|   if (args.length > 0) { |   if (args.length > 0) { | ||||||
|     return function () { |     return function () { | ||||||
|       f.call(this, args[0]) |       f.call(this, args[0]) | ||||||
|     }  |     } | ||||||
|   } else { |   } else { | ||||||
|     return f |     return f | ||||||
|   } |   } | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								reuse/features/support/name-world.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								reuse/features/support/name-world.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | import { setWorldConstructor } from 'cucumber' | ||||||
|  |  | ||||||
|  | setWorldConstructor(function () { | ||||||
|  |   this.names = [] | ||||||
|  | }) | ||||||
							
								
								
									
										50
									
								
								reuse/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										50
									
								
								reuse/package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -625,6 +625,16 @@ | |||||||
|         "regexpu-core": "^4.1.3" |         "regexpu-core": "^4.1.3" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "@babel/polyfill": { | ||||||
|  |       "version": "7.2.5", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.2.5.tgz", | ||||||
|  |       "integrity": "sha512-8Y/t3MWThtMLYr0YNC/Q76tqN1w30+b0uQMeFUYauG2UGTR19zyUtFrAzT23zNtBxPp+LbE5E/nwV/q/r3y6ug==", | ||||||
|  |       "dev": true, | ||||||
|  |       "requires": { | ||||||
|  |         "core-js": "^2.5.7", | ||||||
|  |         "regenerator-runtime": "^0.12.0" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "@babel/preset-env": { |     "@babel/preset-env": { | ||||||
|       "version": "7.2.3", |       "version": "7.2.3", | ||||||
|       "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.2.3.tgz", |       "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.2.3.tgz", | ||||||
| @@ -784,16 +794,6 @@ | |||||||
|         "util.promisify": "^1.0.0" |         "util.promisify": "^1.0.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "babel-runtime": { |  | ||||||
|       "version": "6.26.0", |  | ||||||
|       "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", |  | ||||||
|       "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", |  | ||||||
|       "dev": true, |  | ||||||
|       "requires": { |  | ||||||
|         "core-js": "^2.4.0", |  | ||||||
|         "regenerator-runtime": "^0.11.0" |  | ||||||
|       } |  | ||||||
|     }, |  | ||||||
|     "balanced-match": { |     "balanced-match": { | ||||||
|       "version": "1.0.0", |       "version": "1.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", |       "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", | ||||||
| @@ -967,13 +967,13 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "cucumber": { |     "cucumber": { | ||||||
|       "version": "5.0.3", |       "version": "5.1.0", | ||||||
|       "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-5.0.3.tgz", |       "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-5.1.0.tgz", | ||||||
|       "integrity": "sha512-FsOKcEquPTVzK2sDqshI3Bw8ETztNIrMQ5+Ph8Z8QNaStl7cvIS3M9/T+9zeXvadPJX0jUWkbWcJ91x4gBw9Fg==", |       "integrity": "sha512-zrl2VYTBRgvxucwV2GKAvLqcfA1Naeax8plPvWgPEzl3SCJiuPPv3WxBHIRHtPYcEdbHDR6oqLpZP4bJ8UIdmA==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "requires": { |       "requires": { | ||||||
|  |         "@babel/polyfill": "^7.2.3", | ||||||
|         "assertion-error-formatter": "^2.0.1", |         "assertion-error-formatter": "^2.0.1", | ||||||
|         "babel-runtime": "^6.11.6", |  | ||||||
|         "bluebird": "^3.4.1", |         "bluebird": "^3.4.1", | ||||||
|         "cli-table3": "^0.5.1", |         "cli-table3": "^0.5.1", | ||||||
|         "colors": "^1.1.2", |         "colors": "^1.1.2", | ||||||
| @@ -994,7 +994,7 @@ | |||||||
|         "mz": "^2.4.0", |         "mz": "^2.4.0", | ||||||
|         "progress": "^2.0.0", |         "progress": "^2.0.0", | ||||||
|         "resolve": "^1.3.3", |         "resolve": "^1.3.3", | ||||||
|         "serialize-error": "^2.1.0", |         "serialize-error": "^3.0.0", | ||||||
|         "stack-chain": "^2.0.0", |         "stack-chain": "^2.0.0", | ||||||
|         "stacktrace-js": "^2.0.0", |         "stacktrace-js": "^2.0.0", | ||||||
|         "string-argv": "0.1.1", |         "string-argv": "0.1.1", | ||||||
| @@ -1418,8 +1418,7 @@ | |||||||
|     "lodash": { |     "lodash": { | ||||||
|       "version": "4.17.11", |       "version": "4.17.11", | ||||||
|       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", |       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", | ||||||
|       "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", |       "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" | ||||||
|       "dev": true |  | ||||||
|     }, |     }, | ||||||
|     "loose-envify": { |     "loose-envify": { | ||||||
|       "version": "1.4.0", |       "version": "1.4.0", | ||||||
| @@ -1660,6 +1659,11 @@ | |||||||
|       "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", |       "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|  |     "ramda": { | ||||||
|  |       "version": "0.26.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz", | ||||||
|  |       "integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==" | ||||||
|  |     }, | ||||||
|     "regenerate": { |     "regenerate": { | ||||||
|       "version": "1.4.0", |       "version": "1.4.0", | ||||||
|       "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", |       "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", | ||||||
| @@ -1676,9 +1680,9 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "regenerator-runtime": { |     "regenerator-runtime": { | ||||||
|       "version": "0.11.1", |       "version": "0.12.1", | ||||||
|       "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", |       "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", | ||||||
|       "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", |       "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "regenerator-transform": { |     "regenerator-transform": { | ||||||
| @@ -1761,9 +1765,9 @@ | |||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "serialize-error": { |     "serialize-error": { | ||||||
|       "version": "2.1.0", |       "version": "3.0.0", | ||||||
|       "resolved": "http://registry.npmjs.org/serialize-error/-/serialize-error-2.1.0.tgz", |       "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-3.0.0.tgz", | ||||||
|       "integrity": "sha1-ULZ51WNc34Rme9yOWa9OW4HV9go=", |       "integrity": "sha512-+y3nkkG/go1Vdw+2f/+XUXM1DXX1XcxTl99FfiD/OEPUNw4uo0i6FKABfTAN5ZcgGtjTRZcEbxcE/jtXbEY19A==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "shebang-command": { |     "shebang-command": { | ||||||
|   | |||||||
| @@ -14,6 +14,10 @@ | |||||||
|     "@babel/register": "^7.0.0", |     "@babel/register": "^7.0.0", | ||||||
|     "babel-loader": "^8.0.4", |     "babel-loader": "^8.0.4", | ||||||
|     "chai": "^4.2.0", |     "chai": "^4.2.0", | ||||||
|     "cucumber": "^5.0.3" |     "cucumber": "^5.1.0" | ||||||
|  |   }, | ||||||
|  |   "dependencies": { | ||||||
|  |     "lodash": "^4.17.11", | ||||||
|  |     "ramda": "^0.26.1" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user