-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep_implementation.js
42 lines (31 loc) · 1020 Bytes
/
step_implementation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* globals gauge*/
"use strict";
var assert = require("assert");
var vowels = ["a", "e", "i", "o", "u"];
var numberOfVowels = function (word) {
var vowelArr = word.split("").filter(function (elem) { return vowels.indexOf(elem) > -1; });
return vowelArr.length;
};
// --------------------------
// Gauge step implementations
// --------------------------
step("Vowels in English language are <vowels>.", function(vowelsGiven) {
assert.equal(vowelsGiven, vowels.join(""));
});
step("The word <word> has <number> vowels.", function(word, number) {
assert.equal(number, numberOfVowels(word));
});
step("Almost all words have vowels <table>", function(table) {
table.rows.forEach(function (row) {
assert.equal(numberOfVowels(row.cells[0]), parseInt(row.cells[1]));
});
});
// ---------------
// Execution Hooks
// ---------------
beforeScenario(function () {
assert.equal(vowels.join(""), "aeiou");
});
beforeScenario(function () {
assert.equal(vowels[0], "a");
}, { tags: [ "single word" ]});