var { defineSupportCode } = require('cucumber');

defineSupportCode(function({addTransform}) {
  addTransform({
    typeName: 'shouldToBoolean',
    captureGroupRegexps: ['should|should not'],
    transformer: transform.shouldToBoolean
  });

  addTransform({
    typeName: 'elementName',
    captureGroupRegexps: ['[^"]*'],
    transformer: transform.stringToVariableName
  });

  addTransform({
    typeName: 'elementType',
    captureGroupRegexps: [' button| checkbox| drop down list| field| link| select| tab|'],
    transformer: transform.elementTypeToVariableName
  });

  addTransform({
    typeName: 'captureString',
    captureGroupRegexps: ['[^"]*'],
    transformer: function(string) { return string; }
  });
});

var transform = new Transform();

function Transform() {
  this.shouldToBoolean = function(expectation) {
    return expectation === 'should';
  };

  this.stringToVariableName = function(string) {
    var firstWord, i, len, varName, word, words;

    varName = "";
    string = string.replace('&', 'And');

    words = string.split(' ');
    firstWord = words.shift();
    varName += firstWord.charAt(0).toLowerCase() + firstWord.substring(1);

    words = words.map(function(word) {
      return word.charAt(0).toUpperCase() + word.substring(1);
    });

    for (i = 0; i < words.length; i++) {
      word = words[i];
      varName += word;
    }

    return varName;
  };

  this.elementTypeToVariableName = function(string) {
    string = string.trim();
    if (string === "drop down list") {
      return "Select";
    } else {
      return string.charAt(0).toUpperCase() + string.substring(1);
    }
  };
};

module.exports = Transform;

@@ -75,102 +75,70 @@
 on(%7B
-addTransform%7D) %7B%0A  addTransform(%7B%0A    typeName: 'shouldToBoolean',%0A    captureGroupR
+defineParameterType%7D) %7B%0A  defineParameterType(%7B%0A    r
 egexp
-s
 : 
-%5B'
+/(
 shou
@@ -150,18 +150,18 @@
 ould not
-'%5D
+)/
 ,%0A    tr
@@ -200,96 +200,92 @@
 lean
-%0A  %7D);%0A%0A  addTransform(%7B%0A    typeName: 'elementName',%0A    captureGroupR
+,%0A    typeName: 'shouldToBoolean'%0A  %7D);%0A%0A  defineParameterType(%7B%0A    r
 egexp
-s
 : 
-%5B'
+/
 %5B%5E%22%5D*
-'%5D
+/
 ,%0A  
@@ -333,32 +333,9 @@
 Name
-%0A  %7D);%0A%0A  addTransform(%7B
+,
 %0A   
@@ -357,42 +357,59 @@
 ment
-Typ
+Nam
 e'
-,
 %0A  
-  captureGroupR
+%7D);%0A%0A  defineParameterType(%7B%0A    r
 egexp
-s
 : 
-%5B'
+/(
  but
@@ -464,18 +464,18 @@
 ct%7C tab%7C
-'%5D
+)/
 ,%0A    tr
@@ -524,98 +524,88 @@
 Name
-%0A  %7D);%0A%0A  addTransform(%7B%0A    typeName: 'captureString',%0A    captureGroupR
+,%0A    typeName: 'elementType'%0A  %7D);%0A%0A  defineParameterType(%7B%0A    r
 egexp
-s
 : 
-%5B'
+/
 %5B%5E%22%5D*
-'%5D
+/
 ,%0A  
@@ -654,16 +654,47 @@
 tring; %7D
+,%0A    typeName: 'captureString'
 %0A  %7D);%0A%7D

Remove addTransform