Permalink
Browse files

Minor change to stepdef snippets (JS)

  • Loading branch information...
1 parent cb3b0ad commit 4b24a82e4fe2e5f19f46ff44490b8a10306569dd @jbpros jbpros committed Nov 29, 2013
View
30 features/step_definitions/cucumber_js_mappings.rb
@@ -59,11 +59,11 @@ def write_failing_mapping_with_message(step_name, message)
end
def write_asynchronously_failing_mapping_with_message(step_name, message)
- append_step_definition(step_name, "setTimeout(function() { callback.fail('#{message}');}, 10);")
+ append_step_definition(step_name, "setTimeout(function () { callback.fail('#{message}');}, 10);")
end
def write_asynchronously_failing_mapping_through_exception_with_message(step_name, message)
- append_step_definition(step_name, "setTimeout(function() { throw new Error('#{message}');}, 10);")
+ append_step_definition(step_name, "setTimeout(function () { throw new Error('#{message}');}, 10);")
end
def write_failing_mapping_through_nodejs_callback(step_name)
@@ -83,7 +83,7 @@ def write_mapping_logging_world_variable_value(step_name, time = "1")
def write_mapping_calling_world_function(step_name)
step_def = <<-EOF
-this.someFunction(); callback();
+this.someFunction (); callback();
EOF
append_step_definition(step_name, step_def)
end
@@ -147,14 +147,14 @@ def write_custom_world_constructor
def write_custom_world_constructor_calling_back_with_explicit_object
append_support_code "this.World = function CustomWorldConstructor(callback) {
callback({
- someFunction: function() { fs.writeFileSync(\"#{EXPLICIT_WORLD_OBJECT_FUNCTION_LOG_FILE}\", \"\")}
+ someFunction: function () { fs.writeFileSync(\"#{EXPLICIT_WORLD_OBJECT_FUNCTION_LOG_FILE}\", \"\")}
});
};\n"
end
def write_world_function
append_support_code <<-EOF
-this.World.prototype.someFunction = function() {
+this.World.prototype.someFunction = function () {
fs.writeFileSync("#{WORLD_FUNCTION_LOG_FILE}", "");
};
EOF
@@ -176,17 +176,17 @@ def write_passing_hook options = {}
if hook_type == "around"
append_support_code <<-EOF
-this.#{define_hook}(#{params}function(scenario, runScenario) {
+this.#{define_hook}(#{params}function (scenario, runScenario) {
this.logCycleEvent('#{log_string}-pre');
- runScenario(function(callback) {
+ runScenario(function (callback) {
this.logCycleEvent('#{log_string}-post');
callback();
});
});
EOF
else
append_support_code <<-EOF
-this.#{define_hook}(#{params}function(scenario, callback) {
+this.#{define_hook}(#{params}function (scenario, callback) {
this.logCycleEvent('#{log_string}');
callback();
});
@@ -296,7 +296,7 @@ def assert_suggested_step_definition_snippet(stepdef_keyword, stepdef_pattern, p
params << "callback"
params = params.join ", "
expected_snippet = <<-EOF
-this.#{stepdef_keyword}(/#{stepdef_pattern}/, function(#{params}) {
+this.#{stepdef_keyword}(/#{stepdef_pattern}/, function (#{params}) {
// express the regexp above with the code you wish you had
callback.pending();
});
@@ -340,7 +340,7 @@ def append_step_definition(step_name, code, params = [])
params_string = params.join(", ")
indented_code = indent_code(code).rstrip
append_support_code <<-EOF
-this.defineStep(/#{step_name}/, function(#{params_string}) {
+this.defineStep(/#{step_name}/, function (#{params_string}) {
fs.writeFileSync("#{step_file(step_name)}", "");
#{indented_code}
});
@@ -353,7 +353,7 @@ def append_support_code(code)
end
def write_main_step_definitions_file
- append_to_file(STEP_DEFINITIONS_FILE, "var fs = require('fs');\nvar stepDefinitions = function() {\n");
+ append_to_file(STEP_DEFINITIONS_FILE, "var fs = require('fs');\nvar stepDefinitions = function () {\n");
append_to_file(STEP_DEFINITIONS_FILE, support_code);
append_to_file(STEP_DEFINITIONS_FILE, "};\nmodule.exports = stepDefinitions;")
end
@@ -370,7 +370,7 @@ def write_coffee_script_definition_file
module.exports = stepDefinitions
EOF
end
-
+
def write_pogo_script_definition_file
@mapping_name = "a PogoScript mapping"
append_to_file POGO_SCRIPT_DEFINITIONS_FILE, <<-EOF
@@ -379,15 +379,15 @@ def write_pogo_script_definition_file
this.define step r/^#{@mapping_name}$/ @(callback)
fs.write file sync ('#{step_file(@mapping_name)}', '')
callback()
-
+
module.exports = step definitions
EOF
end
def write_string_based_pattern_mapping
@mapping_name = "a mapping + fancy characters"
append_support_code <<-EOF
-this.defineStep("a mapping + fancy characters", function(callback) {
+this.defineStep("a mapping + fancy characters", function (callback) {
fs.writeFileSync("#{step_file(@mapping_name)}", "");
callback();
});
@@ -397,7 +397,7 @@ def write_string_based_pattern_mapping
def write_string_based_pattern_mapping_with_parameters
@mapping_name = "a string-based mapping with parameters"
append_support_code <<-EOF
-this.defineStep('a mapping with $word_param "$multi_word_param"', function(p1, p2, callback) {
+this.defineStep('a mapping with $word_param "$multi_word_param"', function (p1, p2, callback) {
fs.writeFileSync("#{step_file(@mapping_name)}", p1 + "\\n" + p2);
callback();
});
View
4 lib/cucumber/support_code/step_definition_snippet_builder_syntax.js
@@ -63,7 +63,7 @@ JavaScriptSyntax.prototype = {
},
getStepDefinitionInner2: function() {
- return ', function(';
+ return ', function (';
},
getStepDefinitionEnd: function() {
@@ -94,4 +94,4 @@ CoffeeScriptSyntax.prototype = {
_.extend(CoffeeScriptSyntax.prototype, Syntax.prototype);
exports.JavaScript = JavaScriptSyntax;
-exports.CoffeeScript = CoffeeScriptSyntax;
+exports.CoffeeScript = CoffeeScriptSyntax;
View
88 spec/cucumber/support_code/step_definition_snippet_builder_syntax_spec.js
@@ -1,143 +1,143 @@
require('../../support/spec_helper');
-describe('Cucumber.SupportCode.StepDefinitionSnippetBuilderSyntax', function() {
+describe('Cucumber.SupportCode.StepDefinitionSnippetBuilderSyntax', function () {
var Cucumber = requireLib('cucumber');
var Syntax = Cucumber.SupportCode.StepDefinitionSnippetBuilderSyntax;
var stepDefinitionEndComment = 'express the regexp above with the code you wish you had';
function testBaseSyntax(syntax) {
- describe('getStepDefinitionDocString()', function() {
- it('returns "string"', function() {
+ describe('getStepDefinitionDocString()', function () {
+ it('returns "string"', function () {
expect(syntax.getStepDefinitionDocString()).toBe('string');
});
});
- describe('getStepDefinitionDataTable()', function() {
- it('returns "table"', function() {
+ describe('getStepDefinitionDataTable()', function () {
+ it('returns "table"', function () {
expect(syntax.getStepDefinitionDataTable()).toBe('table');
});
});
- describe('getStepDefinitionCallback()', function() {
- it('returns "callback"', function() {
+ describe('getStepDefinitionCallback()', function () {
+ it('returns "callback"', function () {
expect(syntax.getStepDefinitionCallback()).toBe('callback');
});
});
- describe('getPatternStart()', function() {
- it('returns "/^"', function() {
+ describe('getPatternStart()', function () {
+ it('returns "/^"', function () {
expect(syntax.getPatternStart()).toBe('/^');
});
});
- describe('getPatternEnd()', function() {
- it('returns "$/"', function() {
+ describe('getPatternEnd()', function () {
+ it('returns "$/"', function () {
expect(syntax.getPatternEnd()).toBe('$/');
});
});
- describe('getContextStepDefinitionFunctionName()', function() {
- it('returns "Given"', function() {
+ describe('getContextStepDefinitionFunctionName()', function () {
+ it('returns "Given"', function () {
expect(syntax.getContextStepDefinitionFunctionName()).toBe('Given');
});
});
- describe('getEventStepDefinitionFunctionName()', function() {
- it('returns "When"', function() {
+ describe('getEventStepDefinitionFunctionName()', function () {
+ it('returns "When"', function () {
expect(syntax.getEventStepDefinitionFunctionName()).toBe('When');
});
});
- describe('getOutcomeStepDefinitionFunctionName()', function() {
- it('returns "Then"', function() {
+ describe('getOutcomeStepDefinitionFunctionName()', function () {
+ it('returns "Then"', function () {
expect(syntax.getOutcomeStepDefinitionFunctionName()).toBe('Then');
});
});
- describe('getNumberMatchingGroup()', function() {
- it('returns (\\d+)', function() {
+ describe('getNumberMatchingGroup()', function () {
+ it('returns (\\d+)', function () {
expect(syntax.getNumberMatchingGroup()).toBe('(\\d+)');
});
});
- describe('getQuotedStringMatchingGroup()', function() {
- it('returns "([^"]*)"', function() {
+ describe('getQuotedStringMatchingGroup()', function () {
+ it('returns "([^"]*)"', function () {
expect(syntax.getQuotedStringMatchingGroup()).toBe('"([^"]*)"');
});
});
- describe('getFunctionParameterSeparator()', function() {
- it('returns ", "', function() {
+ describe('getFunctionParameterSeparator()', function () {
+ it('returns ", "', function () {
expect(syntax.getFunctionParameterSeparator()).toBe(', ');
});
});
- describe('getStepDefinitionEndComment()', function() {
- it('returns "' + stepDefinitionEndComment + '"', function() {
+ describe('getStepDefinitionEndComment()', function () {
+ it('returns "' + stepDefinitionEndComment + '"', function () {
expect(syntax.getStepDefinitionEndComment()).toBe(stepDefinitionEndComment);
});
});
}
- describe('JavaScript', function() {
+ describe('JavaScript', function () {
var syntax = new Syntax.JavaScript();
testBaseSyntax(syntax);
- describe('getStepDefinitionStart()', function() {
- it('returns "this."', function() {
+ describe('getStepDefinitionStart()', function () {
+ it('returns "this."', function () {
expect(syntax.getStepDefinitionStart()).toBe('this.');
});
});
- describe('getStepDefinitionInner1()', function() {
- it('returns "("', function() {
+ describe('getStepDefinitionInner1()', function () {
+ it('returns "("', function () {
expect(syntax.getStepDefinitionInner1()).toBe('(');
});
});
- describe('getStepDefinitionInner2()', function() {
- it('returns ", function("', function() {
- expect(syntax.getStepDefinitionInner2()).toBe(', function(');
+ describe('getStepDefinitionInner2()', function () {
+ it('returns ", function ("', function () {
+ expect(syntax.getStepDefinitionInner2()).toBe(', function (');
});
});
- describe('getStepDefinitionEnd()', function() {
+ describe('getStepDefinitionEnd()', function () {
var str = ") {\n // " + stepDefinitionEndComment + "\n callback.pending();\n});\n";
- it('returns "' + str + '"', function() {
+ it('returns "' + str + '"', function () {
expect(syntax.getStepDefinitionEnd()).toBe(str);
});
});
});
- describe('CoffeeScipt', function() {
+ describe('CoffeeScipt', function () {
var syntax = new Syntax.CoffeeScript();
testBaseSyntax(syntax);
- describe('getStepDefinitionStart()', function() {
- it('returns "@"', function() {
+ describe('getStepDefinitionStart()', function () {
+ it('returns "@"', function () {
expect(syntax.getStepDefinitionStart()).toBe('@');
});
});
- describe('getStepDefinitioninner1()', function() {
- it('returns " "', function() {
+ describe('getStepDefinitioninner1()', function () {
+ it('returns " "', function () {
expect(syntax.getStepDefinitionInner1()).toBe(' ');
});
});
- describe('getStepDefinitionInner2()', function() {
- it('returns ", ("', function() {
+ describe('getStepDefinitionInner2()', function () {
+ it('returns ", ("', function () {
expect(syntax.getStepDefinitionInner2()).toBe(', (');
});
});
- describe('getStepDefinitionEnd()', function() {
+ describe('getStepDefinitionEnd()', function () {
var str = ") ->\n # " + stepDefinitionEndComment + "\n callback.pending()\n";
- it('returns "' + str + '"', function() {
+ it('returns "' + str + '"', function () {
expect(syntax.getStepDefinitionEnd()).toBe(str);
});
});

0 comments on commit 4b24a82

Please sign in to comment.