Skip to content

Commit

Permalink
fix snippet syntax
Browse files Browse the repository at this point in the history
closes #711
resolves #710
  • Loading branch information
charlierudolph committed Dec 30, 2016
1 parent fd78323 commit e3ff263
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion features/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Feature: custom formatter
Message:
Undefined. Implement with the following snippet:
this.Given('an undefined step', function (callback) {
Given('an undefined step', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
6 changes: 3 additions & 3 deletions features/snippets_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Feature: snippets formatter
Then it fails
And it outputs the text:
"""
this.Given('undefined step A', function (callback) {
Given('undefined step A', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
this.When('undefined step B', function (callback) {
When('undefined step B', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
this.Then('undefined step C', function (callback) {
Then('undefined step C', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
6 changes: 3 additions & 3 deletions features/step_definition_snippets_i18n.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ Feature: step definition snippets i18n
Then it fails
And the output contains the text:
"""
this.Given('undefined step A', function (callback) {
Given('undefined step A', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
"""
And the output contains the text:
"""
this.When('undefined step B', function (callback) {
When('undefined step B', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
"""
And the output contains the text:
"""
this.Then('undefined step C', function (callback) {
Then('undefined step C', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
2 changes: 1 addition & 1 deletion features/step_definition_snippets_interfaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: step definition snippets custom syntax
Then it fails
And the output contains the text:
"""
this.Given('an undefined step', <SNIPPET_FUNCTION_KEYWORD_AND_PARAMETERS> {
Given('an undefined step', <SNIPPET_FUNCTION_KEYWORD_AND_PARAMETERS> {
// Write code here that turns the phrase above into concrete actions
<SNIPPET_IMPLEMENTATION>;
});
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/cli_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defineSupportCode(function({When, Then}) {
}
}
parameters.push('callback')
const expectedOutput = 'this.' + step + '(' + regExp + ', function (' + parameters.join(', ') + ') {\n'
const expectedOutput = step + '(' + regExp + ', function (' + parameters.join(', ') + ') {\n'
const actualOutput = normalizeText(this.lastRun.output)
expect(actualOutput).to.include(expectedOutput)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class JavaScriptSnippetSyntax {
}

const snippet =
'this.' + functionName + '(\'' + pattern.replace(/'/g, '\\\'') + '\', ' + functionKeyword + '(' + parameters.join(', ') + ') {' + '\n' +
functionName + '(\'' + pattern.replace(/'/g, '\\\'') + '\', ' + functionKeyword + '(' + parameters.join(', ') + ') {' + '\n' +
' // ' + comment + '\n' +
' ' + implementation + '\n' +
'});'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2, callback) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2, callback) {' + '\n' +
' // comment' + '\n' +
' callback(null, \'pending\');' + '\n' +
'});'
Expand All @@ -26,7 +26,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function *(arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function *(arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -42,7 +42,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -58,7 +58,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -74,7 +74,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern\'', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\\\'\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\\\'\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand Down

0 comments on commit e3ff263

Please sign in to comment.