Skip to content

Commit

Permalink
troupe refresh with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosommi committed Oct 19, 2015
1 parent ed6dc15 commit dc63a3d
Show file tree
Hide file tree
Showing 35 changed files with 1,503 additions and 645 deletions.
46 changes: 41 additions & 5 deletions es5/lib/app.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,52 @@ module.exports = yeoman.generators.Base.extend({
};

//copy feature steps
["_model.common.steps.js", "_model.show.steps.js", "_model.create.steps.js", "_model.update.steps.js", "_model.delete.steps.js", "_model.list.steps.js"].forEach(function (templatePath) {
["_model.show.steps.js", "_model.create.steps.js", "_model.update.steps.js", "_model.delete.steps.js", "_model.list.steps.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_model", "" + context.name);
_this.fs.copyTpl(_this.templatePath("es6/features/steps/" + templatePath), _this.destinationPath("es6/features/steps/" + context.name + "/" + newName), context);
}, this);

//copy fixtures
this.fs.copyTpl(this.templatePath("es6/spec/fixtures/_modelFixtures.json"), this.destinationPath("es6/spec/fixtures/" + context.names + ".json"), context);
//copy common steps
["_common.steps.js", "_accessToken.steps.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/features/steps/" + templatePath), _this.destinationPath("es6/features/steps/" + newName), context);
}, this);

//copy support files
["_hooks.js", "_world.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/features/support/" + templatePath), _this.destinationPath("es6/features/support/" + newName), context);
}, this);

//copy controllers
["_modelController.js", "_applicationController.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_model", "" + context.name).replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/app/controllers/" + templatePath), _this.destinationPath("es6/app/controllers/" + newName), context);
}, this);

//copy managers
["_accountManager.js", "_modelManager.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_model", "" + context.name).replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/app/managers/" + templatePath), _this.destinationPath("es6/app/managers/" + newName), context);
}, this);

//copy model
this.fs.copyTpl(this.templatePath("es6/app/models/_model.js"), this.destinationPath("es6/app/models/" + context.name + ".js"), context);

//copy model spec
this.fs.copyTpl(this.templatePath("es6/spec/_model.spec.js"), this.destinationPath("es6/spec/" + context.name + ".spec.js"), context);

//copy controller
this.fs.copyTpl(this.templatePath("es6/app/controllers/_modelController.js"), this.destinationPath("es6/app/controllers/" + context.name + "Controller.js"), context);
//copy routers
["_modelRouter.js", "_modelRoutes.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_model", "" + context.name).replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/app/routers/" + templatePath), _this.destinationPath("es6/app/routers/" + newName), context);
}, this);

//copy misc
["_errors.js", "_server.js"].forEach(function (templatePath) {
var newName = templatePath.replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/app/" + templatePath), _this.destinationPath("es6/app/" + newName), context);
}, this);
},

install: function yoInstall() {
Expand Down
8 changes: 7 additions & 1 deletion es5/lib/features.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ module.exports = yeoman.generators.Base.extend({
//copy features
["_model.show.feature", "_model.create.feature", "_model.update.feature", "_model.delete.feature", "_model.list.feature"].forEach(function (templatePath) {
var newName = templatePath.replace("_model", "" + context.name);
_this.fs.copyTpl(_this.templatePath("es6/features/" + templatePath), _this.destinationPath("es6/features/" + context.name + "/" + newName), context);
_this.fs.copyTpl(_this.templatePath("es6/features/" + templatePath), _this.destinationPath("features/" + context.name + "/" + newName), context);
}, this);

//copy access token feature
["_accessToken.feature"].forEach(function (templatePath) {
var newName = templatePath.replace("_", "");
_this.fs.copyTpl(_this.templatePath("es6/features/" + templatePath), _this.destinationPath("features/" + newName), context);
}, this);
},

Expand Down
34 changes: 25 additions & 9 deletions es5/spec/app.index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,42 @@ describe("troupe", function () {
}).on("end", done);
});

it("creates step files", function () {
assert.file(["es6/features/steps/" + name + "/" + name + ".common.steps.js", "es6/features/steps/" + name + "/" + name + ".show.steps.js", "es6/features/steps/" + name + "/" + name + ".create.steps.js", "es6/features/steps/" + name + "/" + name + ".update.steps.js", "es6/features/steps/" + name + "/" + name + ".delete.steps.js", "es6/features/steps/" + name + "/" + name + ".list.steps.js"]);
it("creates cucumber js files", function () {
assert.file(["es6/features/steps/" + name + "/" + name + ".show.steps.js", "es6/features/steps/" + name + "/" + name + ".create.steps.js", "es6/features/steps/" + name + "/" + name + ".update.steps.js", "es6/features/steps/" + name + "/" + name + ".delete.steps.js", "es6/features/steps/" + name + "/" + name + ".list.steps.js", "es6/features/steps/accessToken.steps.js", "es6/features/support/hooks.js", "es6/features/support/world.js"]);
});

it("creates the fixture file", function () {
assert.file(["es6/spec/fixtures/" + name + "s.json"]);
it("creates a common step file", function () {
assert.file(["es6/features/steps/common.steps.js"]);
});

it("creates the controller", function () {
assert.file(["es6/app/controllers/" + name + "Controller.js"]);
it("creates the model and his spec", function () {
assert.file(["es6/app/models/" + name + ".js", "es6/spec/" + name + ".spec.js"]);
});

it("creates the controllers", function () {
assert.file(["es6/app/controllers/" + name + "Controller.js", "es6/app/controllers/applicationController.js"]);
});

it("creates the managers", function () {
assert.file(["es6/app/managers/" + name + "Manager.js", "es6/app/managers/accountManager.js"]);
});

it("creates the router", function () {
assert.file(["es6/app/routers/" + name + "Router.js", "es6/app/routers/" + name + "Routes.js"]);
});

it("creates misc files", function () {
assert.file(["es6/app/errors.js", "es6/app/server.js"]);
});

describe("(about the content of every feature)", function () {
it("should have some this.querySpy = on it", function () {
assert.fileContent([["es6/features/steps/" + name + "/" + name + ".show.steps.js", "this.querySpy ="]]);
it("should have some this.database = on it", function () {
assert.fileContent([["es6/features/steps/" + name + "/" + name + ".show.steps.js", "this.database"]]);
});

describe("(controller content)", function () {
it("should have filters for validation", function () {
assert.fileContent([["es6/app/controllers/" + name + "Controller.js", "filters()"], ["es6/app/controllers/" + name + "Controller.js", "[validateId]"], ["es6/app/controllers/" + name + "Controller.js", "[validateData]"]]);
assert.fileContent([["es6/app/controllers/" + name + "Controller.js", "filters()"], ["es6/app/controllers/" + name + "Controller.js", "[pullAccountIdFromRequest]"]]);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion es5/spec/features.index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ describe("troupe:features", function () {
});

it("creates feature files", function () {
assert.file(["es6/features/" + name + "/" + name + ".show.feature", "es6/features/" + name + "/" + name + ".create.feature", "es6/features/" + name + "/" + name + ".update.feature", "es6/features/" + name + "/" + name + ".delete.feature", "es6/features/" + name + "/" + name + ".list.feature"]);
assert.file(["features/" + name + "/" + name + ".show.feature", "features/" + name + "/" + name + ".create.feature", "features/" + name + "/" + name + ".update.feature", "features/" + name + "/" + name + ".delete.feature", "features/" + name + "/" + name + ".list.feature", "features/accessToken.feature"]);
});
});
87 changes: 79 additions & 8 deletions es6/lib/app.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ module.exports = yeoman.generators.Base.extend({
};

//copy feature steps
["_model.common.steps.js",
"_model.show.steps.js",
["_model.show.steps.js",
"_model.create.steps.js",
"_model.update.steps.js",
"_model.delete.steps.js",
Expand All @@ -55,19 +54,91 @@ module.exports = yeoman.generators.Base.extend({
);
}, this);

//copy fixtures
//copy common steps
["_common.steps.js",
"_accessToken.steps.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/features/steps/${templatePath}`),
this.destinationPath(`es6/features/steps/${newName}`),
context
);
}, this);

//copy support files
["_hooks.js",
"_world.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/features/support/${templatePath}`),
this.destinationPath(`es6/features/support/${newName}`),
context
);
}, this);

//copy controllers
["_modelController.js",
"_applicationController.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_model", `${context.name}`).replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/app/controllers/${templatePath}`),
this.destinationPath(`es6/app/controllers/${newName}`),
context
);
}, this);

//copy managers
["_accountManager.js",
"_modelManager.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_model", `${context.name}`).replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/app/managers/${templatePath}`),
this.destinationPath(`es6/app/managers/${newName}`),
context
);
}, this);

//copy model
this.fs.copyTpl(
this.templatePath("es6/spec/fixtures/_modelFixtures.json"),
this.destinationPath(`es6/spec/fixtures/${context.names}.json`),
this.templatePath(`es6/app/models/_model.js`),
this.destinationPath(`es6/app/models/${context.name}.js`),
context
);

//copy controller
//copy model spec
this.fs.copyTpl(
this.templatePath("es6/app/controllers/_modelController.js"),
this.destinationPath(`es6/app/controllers/${context.name}Controller.js`),
this.templatePath(`es6/spec/_model.spec.js`),
this.destinationPath(`es6/spec/${context.name}.spec.js`),
context
);

//copy routers
["_modelRouter.js",
"_modelRoutes.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_model", `${context.name}`).replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/app/routers/${templatePath}`),
this.destinationPath(`es6/app/routers/${newName}`),
context
);
}, this);

//copy misc
["_errors.js",
"_server.js"]
.forEach((templatePath) => {
let newName = templatePath.replace("_", "");
this.fs.copyTpl(
this.templatePath(`es6/app/${templatePath}`),
this.destinationPath(`es6/app/${newName}`),
context
);
}, this);
},

install: function yoInstall() {
Expand Down
13 changes: 12 additions & 1 deletion es6/lib/features.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ module.exports = yeoman.generators.Base.extend({
let newName = templatePath.replace("_model", `${context.name}`);
this.fs.copyTpl(
this.templatePath("es6/features/" + templatePath),
this.destinationPath(`es6/features/${context.name}/${newName}`),
this.destinationPath(`features/${context.name}/${newName}`),
context
);
}, this);

//copy access token feature
["_accessToken.feature"]
.forEach((templatePath) => {
let newName = templatePath.replace("_", "");
this.fs.copyTpl(
this.templatePath("es6/features/" + templatePath),
this.destinationPath(`features/${newName}`),
context
);
}, this);
Expand Down
52 changes: 41 additions & 11 deletions es6/spec/app.index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,70 @@ describe("troupe", () => {
.on("end", done);
});

it("creates step files", () => {
it("creates cucumber js files", () => {
assert.file([
`es6/features/steps/${name}/${name}.common.steps.js`,
`es6/features/steps/${name}/${name}.show.steps.js`,
`es6/features/steps/${name}/${name}.create.steps.js`,
`es6/features/steps/${name}/${name}.update.steps.js`,
`es6/features/steps/${name}/${name}.delete.steps.js`,
`es6/features/steps/${name}/${name}.list.steps.js`
`es6/features/steps/${name}/${name}.list.steps.js`,
`es6/features/steps/accessToken.steps.js`,
`es6/features/support/hooks.js`,
`es6/features/support/world.js`
]);
});

it("creates the fixture file", () => {
it("creates a common step file", () => {
assert.file([
`es6/spec/fixtures/${name}s.json`
`es6/features/steps/common.steps.js`
]);
});

it("creates the controller", () => {
it("creates the model and his spec", () => {
assert.file([
`es6/app/controllers/${name}Controller.js`
`es6/app/models/${name}.js`,
`es6/spec/${name}.spec.js`
]);
});

it("creates the controllers", () => {
assert.file([
`es6/app/controllers/${name}Controller.js`,
`es6/app/controllers/applicationController.js`
]);
});

it("creates the managers", () => {
assert.file([
`es6/app/managers/${name}Manager.js`,
`es6/app/managers/accountManager.js`
]);
});

it("creates the router", () => {
assert.file([
`es6/app/routers/${name}Router.js`,
`es6/app/routers/${name}Routes.js`
]);
});

it("creates misc files", () => {
assert.file([
`es6/app/errors.js`,
`es6/app/server.js`
]);
});

describe("(about the content of every feature)", () => {
it("should have some this.querySpy = on it", () => {
assert.fileContent([[`es6/features/steps/${name}/${name}.show.steps.js`, "this.querySpy ="]]);
it("should have some this.database = on it", () => {
assert.fileContent([[`es6/features/steps/${name}/${name}.show.steps.js`, "this.database"]]);
});

describe("(controller content)", () => {
it("should have filters for validation", () => {
assert.fileContent([
[`es6/app/controllers/${name}Controller.js`, "filters()"],
[`es6/app/controllers/${name}Controller.js`, "[validateId]"],
[`es6/app/controllers/${name}Controller.js`, "[validateData]"]
[`es6/app/controllers/${name}Controller.js`, "[pullAccountIdFromRequest]"]
]);
});
});
Expand Down
11 changes: 6 additions & 5 deletions es6/spec/features.index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ describe("troupe:features", () => {

it("creates feature files", () => {
assert.file([
`es6/features/${name}/${name}.show.feature`,
`es6/features/${name}/${name}.create.feature`,
`es6/features/${name}/${name}.update.feature`,
`es6/features/${name}/${name}.delete.feature`,
`es6/features/${name}/${name}.list.feature`
`features/${name}/${name}.show.feature`,
`features/${name}/${name}.create.feature`,
`features/${name}/${name}.update.feature`,
`features/${name}/${name}.delete.feature`,
`features/${name}/${name}.list.feature`,
`features/accessToken.feature`
]);
});
});
Loading

0 comments on commit dc63a3d

Please sign in to comment.