-
Notifications
You must be signed in to change notification settings - Fork 57
Initial Test Scaffolding #96
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
Changes from all commits
998336f
b10bb20
e05aa0b
a779e18
41deacc
876d72f
2845876
2cab45c
51697c6
6ba7614
2496882
5177bb6
9e01532
51c99ed
ed0dc41
24966a2
f167bfd
caa9e1b
7b969d2
d424d05
4528eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| node_modules/ | ||
| test/temp/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| language: node_js | ||
| node_js: | ||
| - "0.8" | ||
| - "0.10" | ||
| addons: | ||
| hosts: | ||
| - local.generatortest.com | ||
| install: | ||
| - npm install -g bower | ||
| before_script: | ||
| - npm install | ||
| - ./test/support/generate | ||
| - sudo mkdir /vagrant | ||
| - sudo ln -s "${PWD}/test/temp/web" /vagrant/web | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. local.generatortest.com points to |
||
| - sudo ./test/temp/bin/provision | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,8 @@ var WordpressGenerator = function(args, options, config) { | |
| }.bind(this) | ||
| }); | ||
| }); | ||
|
|
||
| this.sourceRoot(path.join(__dirname, 'templates')); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused hours of frustration. For some reason, because this generator isn't it's own repo, I have to set this manually. |
||
| }; | ||
|
|
||
| util.inherits(WordpressGenerator, yeoman.generators.Base); | ||
|
|
@@ -306,7 +308,7 @@ WordpressGenerator.prototype.writeWeb = function() { | |
| this.htaccessFile = ''; | ||
| } | ||
|
|
||
| this.template('web/htaccess', path.join(this.props.web, '.htaccess')); | ||
| this.template('web/htaccess', path.join(this.props.web, '.htaccess')); | ||
| this.template('web/no_robots.txt', path.join(this.props.web, 'no_robots.txt')); | ||
| this.template('web/robots.txt', path.join(this.props.web, 'robots.txt')); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,13 @@ | |
| "ssh-keygen": "~0.2.1", | ||
| "yeoman-generator": "~0.14.0-rc.1" | ||
| }, | ||
| "devDependencies": {}, | ||
| "devDependencies": { | ||
| "hooker": "~0.2.3", | ||
| "mocha": "~1.15.1", | ||
| "zombie": "~2.0.0-alpha24" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "mocha --reporter spec" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More informative than the default "dot" reporter. |
||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| system_packages: | ||
| - build-essential | ||
| - autoconf | ||
| - tasksel | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was required for Travis CI's boxes. I figure it's actually safe to have by default anyway. |
||
| - re2c | ||
| - curl | ||
| - git-core | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| 'use strict'; | ||
|
|
||
| var assert = require('assert'); | ||
| var Browser = require('zombie'); | ||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
|
|
||
| describe('Genesis WordPress', function () { | ||
| describe('generator', function() { | ||
| it('should create required files', function(done) { | ||
| [ | ||
| 'bin/provision', | ||
| 'deployment/deploy.rb', | ||
| 'provisioning/provision.yml', | ||
| 'provisioning/files/ssh/id_rsa', | ||
| 'provisioning/files/ssh/id_rsa.pub', | ||
| 'web/wp-config.php', | ||
| 'bower.json', | ||
| 'Capfile', | ||
| 'README.md', | ||
| 'Vagrantfile', | ||
| ].forEach(function(file) { | ||
| var filePath = path.join(__dirname, 'temp', file); | ||
|
|
||
| assert.ok(fs.existsSync(filePath), 'File not created: ' + filePath); | ||
| }); | ||
|
|
||
| done(); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 'use strict'; | ||
|
|
||
| var assert = require('assert'); | ||
| var Browser = require('zombie'); | ||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
|
|
||
| describe('Genesis WordPress', function () { | ||
| describe('site', function() { | ||
| it('may not be installed', function(done) { | ||
| var browser = new Browser(); | ||
|
|
||
| this.timeout(0); | ||
|
|
||
| browser | ||
| .visit('http://local.generatortest.com/wp-admin/install.php') | ||
| .then(function() { | ||
| if (browser.button('Install WordPress')) { | ||
| browser | ||
| .fill('Site Title', 'Genesis WordPress Test') | ||
| .fill('Username', 'test') | ||
| .fill('admin_password', 'test') | ||
| .fill('admin_password2', 'test') | ||
| .fill('Your E-mail', 'test@example.com') | ||
| .uncheck('blog_public') | ||
| ; | ||
|
|
||
| return browser.pressButton('Install WordPress'); | ||
| } | ||
| }) | ||
| .then(done, done) | ||
| ; | ||
| }); | ||
|
|
||
| it('should be installed', function(done) { | ||
| var browser = new Browser(); | ||
|
|
||
| browser | ||
| .visit('http://local.generatortest.com/wp-admin/install.php') | ||
| .then(function() { | ||
| assert.equal('Log In', browser.text('a.button')); | ||
| }) | ||
| .then(done, done) | ||
| ; | ||
| }) | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| var Generator = require('./generator'); | ||
| var generator = new Generator(); | ||
|
|
||
| generator.run(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| var hooker = require('hooker'); | ||
| var path = require('path'); | ||
| var helpers = require('yeoman-generator').test; | ||
|
|
||
| var Generator = function() {}; | ||
|
|
||
| Generator.prototype.create = function() { | ||
| this.app = helpers.createGenerator('genesis-wordpress:app', [ | ||
| [require('../../generator/app'), 'genesis-wordpress:app'] | ||
| ]); | ||
| }; | ||
|
|
||
| Generator.prototype.prompts = function() { | ||
| hooker.hook(this.app, 'prompt', function(prompts, done) { | ||
| var answers = { | ||
| name: 'GeneratorTest.com', | ||
| domain: 'generatortest.com', | ||
| ip: '192.168.137.137', | ||
| DB_NAME: 'generator_test', | ||
| DB_USER: 'generator_test', | ||
| DB_PASSWORD: 'generator_test' | ||
| }; | ||
|
|
||
| prompts.forEach(function(prompt) { | ||
| if (answers[prompt.name]) { | ||
| return; | ||
| } | ||
|
|
||
| if (prompt.default instanceof Function) { | ||
| answers[prompt.name] = prompt.default(answers); | ||
| } else { | ||
| answers[prompt.name] = prompt.default; | ||
| } | ||
| }); | ||
|
|
||
| hooker.unhook(this.app, 'prompt'); | ||
|
|
||
| done(answers); | ||
|
|
||
| return hooker.preempt(answers); | ||
| }.bind(this)); | ||
| }; | ||
|
|
||
| Generator.prototype.run = function() { | ||
| helpers.testDirectory(path.join(__dirname, '..', 'temp'), function(err) { | ||
| if (err) { | ||
| throw err; | ||
| } | ||
|
|
||
| this.create(); | ||
| this.prompts(); | ||
|
|
||
| this.app.run({}, function() {}); | ||
| }.bind(this)); | ||
| }; | ||
|
|
||
|
|
||
| module.exports = Generator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the crux to it all working.