Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[minor] Fix some whitespace issues in step generation

  • Loading branch information...
commit 2d58999778b5b9c8e1bc2b0532fa253804748311 1 parent 197b325
@indexzero indexzero authored
View
2  .gitignore
@@ -1,2 +1,4 @@
test/output/*.js
+test/output/vows/*.js
+test/output/steps/*.js
test/beta-test.js
View
14 lib/kyuri/generator.js
@@ -29,10 +29,15 @@ var load = function (files, templateDir) {
return templates;
}
+var capitalize = function (str) {
+ return str && str[0].toUpperCase() + str.slice(1).toLowerCase();
+}
+
var Generator = function (ast) {
this.ast = ast;
this.templateDir = 'templates/vows';
this.doIndent = true;
+ this.trim = false;
this.files = {
'step': 'step.tmpl',
'topic': 'topic.tmpl',
@@ -76,6 +81,10 @@ Generator.prototype = {
template = _.template(this.templates['feature']);
rendered = template(context);
+ if (this.trim) {
+ rendered = rendered.replace(/\t/g, '');
+ }
+
return {
name: feature.name,
text: rendered
@@ -121,7 +130,7 @@ Generator.prototype = {
template = _.template(this.templates['topic']);
rendered = template({
title: step.join(' '),
- operator: step[0],
+ operator: capitalize(step[0]),
next: next
});
return this.doIndent ? this.indent(rendered) : rendered;
@@ -134,7 +143,7 @@ Generator.prototype = {
template = _.template(this.templates['step']);
rendered = template({
title: step.join(' '),
- operator: step[0]
+ operator: capitalize(step[0])
});
return this.doIndent ? this.indent(rendered) : rendered;
@@ -164,6 +173,7 @@ var StepGenerator = function (ast) {
this.ast = ast;
this.templateDir = 'templates/steps';
this.doIndent = false;
+ this.trim = true;
this.files = {
'step': 'step.js.tmpl',
'topic': 'topic.js.tmpl',
View
6 lib/kyuri/templates/steps/feature.js.tmpl
@@ -1,13 +1,11 @@
/*
* {{title}}.feature
- * Step definitions for \'{{title}}\'
+ * Step definitions for Feature: \'{{title}}\'
*
* Auto-generated using Kyuri: http://github.com/nodejitsu/kyuri
*/
var kyuri = require(\'kyuri\'),
- Steps = require(\'kyuri\').Steps;
-
-{{scenarios}}
+ Steps = require(\'kyuri\').Steps;{{scenarios}}
Steps.export(module);
View
4 lib/kyuri/templates/steps/scenario.js.tmpl
@@ -1,2 +1,6 @@
+
+
+//
// Step definitions for Scenario: {{title}}
+//
{{body}}
View
1  test/output/Placeholder.txt
@@ -1 +0,0 @@
-This is a placeholder to get git to create this folder
Please sign in to comment.
Something went wrong with that request. Please try again.