Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Custom Snippet for Unimplemented file name suggestion #464

Closed
xywang68 opened this issue Sep 2, 2016 · 3 comments
Closed

Use Custom Snippet for Unimplemented file name suggestion #464

xywang68 opened this issue Sep 2, 2016 · 3 comments

Comments

@xywang68
Copy link

xywang68 commented Sep 2, 2016

Back in 0.35.0 chimp will suggest a file name and print a skeleton file for the steps that are missing.
i.e.:

// Recommended filename: When_I_search_and_open_the_test_portfolio.js
module.exports = function() {
  this.When(/^I search and open the test portfolio$/, function () {
    // Write the automation code here
    pending();
  });
};

This feature seems to be missing in 0.40.4.
Now it becomes:

   Message:
     Undefined. Implement with the following snippet:
   this.When(/^I search and open the test portfolioe$/, function (callback) {
     // Write code here that turns the phrase above into concrete actions
     callback(null, 'pending');
   });

Is this an intended change and why? or is it a configurable setting? I think the original feature is very nice and I would like to get it back.

@xywang68
Copy link
Author

xywang68 commented Sep 6, 2016

Looks like this issue is due to cucumber updated its pending code snippet message.
Here is a temporary fix that seem to work:
(based on 0.40.0, ~/node_modules/chimp/dist/lib/cucumberjs/cucumber.js)

156 // Orig:
157 //    if (message.indexOf('callback.pending()') === -1) {
158 // Fix:
159       if (message.indexOf('callback(null, \'pending\')') === -1) {
160         process.stdout.write(message);
161         return;
162       }
163 
164       try {
165         (function () {
166           var defaultText = 'Write code here that turns the phrase above into concrete actions';
167           var replacementText = 'Write the automation code here';
168           var tab = '';
169           var self = _this3;
170           _.each(message.split('\n'), function (eachLine) {
171             if (booleanHelper.isTruthy(self.options.singleSnippetPerFile) && eachLine.match(/this\./)) {
172               process.stdout.write('// Recommended filename: '.gray + (self._getRecommendedFilename(eachLine) + '.js\n').cyan);
173               process.stdout.write('module.exports = function() {\n'.yellow);
174               tab = '  ';
175             }
176             var line = eachLine;
177             line = line.replace(defaultText, replacementText);
178 // Orig:
179 //          line = line.replace('callback.pending()', 'pending()');
180 // Fix: 
181             line = line.replace('callback(null, \'pending\')', 'pending()');
182             line = line.replace(', callback', '');
183             line = line.replace('callback', '');
184             process.stdout.write(tab + line + '\n');

@samhatoum
Copy link
Member

Thank you, I aim to rewrite this using the new custom snippet function in 1.3

@samhatoum samhatoum changed the title Unimplemented file name suggestion is missing after 0.35.0 Use Custom Snippet for Unimplemented file name suggestion Sep 22, 2016
@samhatoum
Copy link
Member

This issue is being tracked in Chimpy
https://github.com/TheBrainFamily/chimpy/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants