Skip to content

Commit d577a8b

Browse files
committed
Updated all the tests and fixed the deploy task
Added a bunch more tests that checks for the gulpfile tasks, that the correct packages are installed in the package.json file and removed the test-util.js file as it's no longer needed. Also fixed the gulpfile always containing a deploy task even when you selected that you didn't use it and added tests that checks for it.
1 parent caf91fc commit d577a8b

File tree

11 files changed

+150
-148
lines changed

11 files changed

+150
-148
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ previously installed nothing will change, this is just an informal update.
3434
* **Feed:** Updated the feed to be more up to par and completely valid
3535
* **Packages:** Updated the packages to be more up to date on NPM
3636

37+
#### Behind the scenes
38+
* **Tests:** Continued working on tests to make errors even less likely. Yay
39+
tests.
40+
3741
<a name="0.7.1"></a>
3842
## 0.7.1 - Bugfix
3943

app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ module.exports = yeoman.generators.Base.extend({
231231
this.amazonCloudfrontS3 = hasFeature("amazonCloudfrontS3");
232232
this.rsync = hasFeature("rsync");
233233
this.githubPages = hasFeature("githubPages");
234+
this.noUpload = hasFeature("noUpload");
234235

235236
this.amazonKey = props.amazonKey;
236237
this.amazonSecret = props.amazonSecret;

app/templates/gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ gulp.task("optimize", gulp.series(
273273
gulp.task("build", gulp.series(
274274
gulp.series(jekyllDev),
275275
gulp.parallel(styles, javascript, fonts, images)
276-
));
276+
));<% if (!noUpload) { %>
277277

278278
// Deploy your site for all to see
279-
gulp.task("deploy", deploy);
279+
gulp.task("deploy", deploy);<% } %>
280280

281281
// Serves your site locally
282282
gulp.task("serve", serve);

test-util.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/test-creation-aws.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var path = require("path");
55
var helpers = require("yeoman-generator").test;
66
var assert = require("yeoman-generator").assert;
7-
var tasks = require("../test-util.js");
87

98
describe("Jekyllized generator test when using Amazon AWS", function () {
109
before(function (done) {
@@ -36,8 +35,28 @@ describe("Jekyllized generator test when using Amazon AWS", function () {
3635
assert.file(expected);
3736
});
3837

39-
it("should contain deploy tasks", function (done) {
40-
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
38+
it("should contain the correct deploy function", function () {
39+
assert.fileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
40+
});
41+
42+
it("should NOT contain either the GH Pages or Rsync function", function () {
43+
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
44+
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
45+
});
46+
47+
it("should contain deploy tasks", function () {
48+
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
49+
});
50+
51+
it("should contain the correct packages", function () {
52+
var expected = [
53+
["package.json", /\"concurrent-transform\"/],
54+
["package.json", /\"gulp-awspublish\"/],
55+
["package.json", /\"gulp-awspublish-router\"/],
56+
["package.json", /\"gulp-cloudfront\"/]
57+
];
58+
59+
assert.fileContent(expected);
4160
});
4261

4362
});

test/test-creation-ghpages.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var path = require("path");
55
var helpers = require("yeoman-generator").test;
66
var assert = require("yeoman-generator").assert;
7-
var tasks = require("../test-util.js");
87

98
describe("Jekyllized generator test when using GitHub Pages", function () {
109
before(function (done) {
@@ -31,8 +30,21 @@ describe("Jekyllized generator test when using GitHub Pages", function () {
3130
assert.file(expected);
3231
});
3332

34-
it("should contain deploy task", function (done) {
35-
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
33+
it("should contain the correct deploy function", function () {
34+
assert.fileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
35+
});
36+
37+
it("should NOT contain either the Amazon or Rsync function", function () {
38+
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
39+
assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
40+
});
41+
42+
it("should contain deploy tasks", function () {
43+
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
44+
});
45+
46+
it("should contain the correct packages", function () {
47+
assert.fileContent("package.json", /\"gulp-gh-pages\"/);
3648
});
3749

3850
});

test/test-creation-rsync.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var path = require("path");
55
var helpers = require("yeoman-generator").test;
66
var assert = require("yeoman-generator").assert;
7-
var tasks = require("../test-util.js");
87

98
describe("Jekyllized generator test when using Rsync", function () {
109
before(function (done) {
@@ -35,8 +34,21 @@ describe("Jekyllized generator test when using Rsync", function () {
3534
assert.file(expected);
3635
});
3736

38-
it("should contain deploy task", function (done) {
39-
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
37+
it("should contain the correct deploy function", function () {
38+
assert.fileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
39+
});
40+
41+
it("should NOT contain either the GH Pages or Amazon function", function () {
42+
assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
43+
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
44+
});
45+
46+
it("should contain deploy tasks", function () {
47+
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
48+
});
49+
50+
it("should contain the correct packages", function () {
51+
assert.fileContent("package.json", /\"gulp-rsync\"/);
4052
});
4153

4254
});

test/test-gulp.js

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var path = require("path");
55
var assert = require("assert");
66
var helpers = require("yeoman-generator").test;
7-
var tasks = require("../test-util.js");
87

98
describe("Jekyllized generator test for Gulp tasks without any uploading", function () {
109
before(function (done) {
@@ -50,44 +49,24 @@ describe("Jekyllized generator test for Gulp tasks without any uploading", funct
5049
assert.noFile(unexpected);
5150
});
5251

53-
it("should contain default task", function (done) {
54-
tasks.assertTaskExists(this.jekyllized, "default", [], done);
55-
});
56-
57-
it("should contain optimize task", function (done) {
58-
tasks.assertTaskExists(this.jekyllized, "optimize", [], done);
59-
});
60-
61-
it("should contain build task", function (done) {
62-
tasks.assertTaskExists(this.jekyllized, "build", [], done);
63-
});
64-
65-
it("should contain deploy task", function (done) {
66-
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
67-
});
68-
69-
it("should contain serve task", function (done) {
70-
tasks.assertTaskExists(this.jekyllized, "serve", [], done);
71-
});
72-
73-
it("should contain clean task", function (done) {
74-
tasks.assertTaskExists(this.jekyllized, "clean", [], done);
75-
});
76-
77-
it("should contain rebuild task", function (done) {
78-
tasks.assertTaskExists(this.jekyllized, "rebuild", [], done);
79-
});
80-
81-
it("should contain styles task", function (done) {
82-
tasks.assertTaskExists(this.jekyllized, "styles", [], done);
83-
});
52+
it ("should contain the standard tasks", function () {
53+
var expected = [
54+
["gulpfile.js", /gulp.task\(\"default\"/],
55+
["gulpfile.js", /gulp.task\(\"optimize\"/],
56+
["gulpfile.js", /gulp.task\(\"build\"/],
57+
["gulpfile.js", /gulp.task\(\"serve\"/],
58+
["gulpfile.js", /gulp.task\(\"clean\"/],
59+
["gulpfile.js", /gulp.task\(\"rebuild\"/],
60+
["gulpfile.js", /gulp.task\(\"styles\"/],
61+
["gulpfile.js", /gulp.task\(\"javascript\"/],
62+
["gulpfile.js", /gulp.task\(\"check\"/]
63+
];
8464

85-
it("should contain javascript task", function (done) {
86-
tasks.assertTaskExists(this.jekyllized, "javascript", [], done);
65+
assert.fileContent(expected);
8766
});
8867

89-
it("should contain check task", function (done) {
90-
tasks.assertTaskExists(this.jekyllized, "check", [], done);
68+
it("should NOT contain a deploy task", function () {
69+
assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
9170
});
9271

9372
});

test/test-jekyll.js

Lines changed: 37 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var path = require("path");
55
var helpers = require("yeoman-generator").test;
66
var assert = require("yeoman-generator").assert;
7-
var tasks = require("../test-util.js");
87

98
describe("Jekyllized generator", function () {
109
describe("test for Jekyll settings", function () {
@@ -44,64 +43,39 @@ describe("Jekyllized generator", function () {
4443
});
4544

4645
it("gulpfile.js does NOT contain a deploy task", function () {
47-
assert.noFileContent("gulpfile.js", /gulp.task \("deploy"\)/);
46+
assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
4847
});
4948

50-
it("_config.yml contains the correct title", function (done) {
51-
tasks.assertJekyllSettings(this.jekyllized, "title", "Mocha Test", done);
52-
});
53-
54-
it("_config.yml contains the correct description", function (done) {
55-
tasks.assertJekyllSettings(this.jekyllized, "description", "Mocha tests for Jekyllized", done);
56-
});
57-
58-
it("_config.yml contains the correct tagline", function (done) {
59-
tasks.assertJekyllSettings(this.jekyllized, "tagline", "Better hope this doesn\"t blow up", done);
60-
});
61-
62-
it("_config.yml contains the correct author name", function (done) {
63-
tasks.assertJekyllSettings(this.jekyllized, "name", "Ola Nordmann", done);
64-
});
65-
66-
it("_config.yml contains the correct author email", function (done) {
67-
tasks.assertJekyllSettings(this.jekyllized, "email", "ola.nordmann@email.com", done);
68-
});
69-
70-
it("_config.yml contains the correct author bio", function (done) {
71-
tasks.assertJekyllSettings(this.jekyllized, "bio", "Just your average Norwegian", done);
72-
});
73-
74-
it("_config.yml contains the correct author Twitter", function (done) {
75-
tasks.assertJekyllSettings(this.jekyllized, "twitter", "olanordmann123123", done);
76-
});
77-
78-
it("_config.build.yml contains the corrent setting for future posts", function (done) {
79-
tasks.assertJekyllBuildSettings(this.jekyllized, "future", "false", done);
80-
});
81-
82-
it("_config.build.yml contains the corrent setting for drafts", function (done) {
83-
tasks.assertJekyllBuildSettings(this.jekyllized, "show_drafts", "false", done);
84-
});
85-
86-
it("_config.build.yml contains the corrent setting for LSI", function (done) {
87-
tasks.assertJekyllBuildSettings(this.jekyllized, "lsi", "true", done);
88-
});
49+
it("_config.yml contains the correct settings", function () {
50+
var expected = [
51+
["_config.yml", /title\: Mocha Test/],
52+
["_config.yml", /description\: Mocha tests for Jekyllized/],
53+
["_config.yml", /tagline\: Better hope this doesn\"t blow up/],
54+
["_config.yml", /name\: Ola Nordmann/],
55+
["_config.yml", /email\: ola\.nordmann\@email\.com/],
56+
["_config.yml", /bio\: Just your average Norwegian/],
57+
["_config.yml", /twitter\: olanordmann123123/]
58+
];
8959

90-
it("_config.build.yml contains the corrent setting for limiting posts", function (done) {
91-
tasks.assertJekyllBuildSettings(this.jekyllized, "limit_posts", "0", done);
60+
assert.fileContent(expected);
9261
});
9362

94-
it("_config.build.yml contains the corrent setting for source dir", function (done) {
95-
tasks.assertJekyllBuildSettings(this.jekyllized, "source", "src", done);
96-
});
63+
it("_config.build.yml contains the correct settings", function () {
64+
var expected = [
65+
["_config.build.yml", /future\: false/],
66+
["_config.build.yml", /show_drafts\: false/],
67+
["_config.build.yml", /lsi\: true/],
68+
["_config.build.yml", /limit_posts\: 0/],
69+
["_config.build.yml", /source\: src/],
70+
["_config.build.yml", /destination\: dist/]
71+
];
9772

98-
it("_config.build.yml contains the corrent setting for destination dir", function (done) {
99-
tasks.assertJekyllBuildSettings(this.jekyllized, "destination", "dist", done);
73+
assert.fileContent(expected);
10074
});
10175

10276
});
10377

104-
describe("test pretty permalinks and 10 pages", function () {
78+
describe("test with setting pretty permalinks and 10 posts per page", function () {
10579
before(function (done) {
10680
helpers.run(path.join(__dirname, "../app"))
10781
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination"))
@@ -114,17 +88,17 @@ describe("Jekyllized generator", function () {
11488
.on("end", done);
11589
});
11690

117-
it("_config.yml permalink setting is 'pretty'", function (done) {
118-
tasks.assertJekyllSettings(this.jekyllized, "permalink", "pretty", done);
91+
it("_config.yml permalink setting is 'pretty'", function () {
92+
assert.fileContent("_config.yml", /permalink\: pretty/);
11993
});
12094

121-
it("_config.yml pagination setting is '10'", function (done) {
122-
tasks.assertJekyllSettings(this.jekyllized, "paginate", "10", done);
95+
it("_config.yml pagination is '10' posts per page", function () {
96+
assert.fileContent("_config.yml", /paginate\: 10/);
12397
});
12498

12599
});
126100

127-
describe("test date permalinks and all pages", function () {
101+
describe("test with setting date permalinks and all posts on the same page", function () {
128102
before(function (done) {
129103
helpers.run(path.join(__dirname, "../app"))
130104
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination-1"))
@@ -137,17 +111,17 @@ describe("Jekyllized generator", function () {
137111
.on("end", done);
138112
});
139113

140-
it("_config.yml permalink setting is 'date'", function (done) {
141-
tasks.assertJekyllSettings(this.jekyllized, "permalink", "date", done);
114+
it("_config.yml permalink setting is 'date'", function () {
115+
assert.fileContent("_config.yml", /permalink\: date/);
142116
});
143117

144-
it("_config.yml pagination setting is 'all'", function (done) {
145-
tasks.assertJekyllSettings(this.jekyllized, "paginate", "all", done);
118+
it("_config.yml pagination is 'all' posts per page", function () {
119+
assert.fileContent("_config.yml", /paginate\: all/);
146120
});
147121

148122
});
149123

150-
describe("test no permalinks and 1 page", function () {
124+
describe("test with no permalinks setting and 1 post per page", function () {
151125
before(function (done) {
152126
helpers.run(path.join(__dirname, "../app"))
153127
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination-2"))
@@ -160,12 +134,12 @@ describe("Jekyllized generator", function () {
160134
.on("end", done);
161135
});
162136

163-
it("_config.yml permalink setting is 'none'", function (done) {
164-
tasks.assertJekyllSettings(this.jekyllized, "permalink", "none", done);
137+
it("_config.yml permalink setting is 'none'", function () {
138+
assert.fileContent("_config.yml", /permalink\: none/);
165139
});
166140

167-
it("_config.yml pagination setting is '1'", function (done) {
168-
tasks.assertJekyllSettings(this.jekyllized, "paginate", "1", done);
141+
it("_config.yml pagination is '1' posts per page", function () {
142+
assert.fileContent("_config.yml", /paginate\: 1/);
169143
});
170144

171145
});

0 commit comments

Comments
 (0)