Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
test/temp/
15 changes: 15 additions & 0 deletions .travis.yml
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
Copy link
Copy Markdown
Contributor Author

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.

install:
- npm install -g bower
before_script:
- npm install
- ./test/support/generate
- sudo mkdir /vagrant
- sudo ln -s "${PWD}/test/temp/web" /vagrant/web
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local.generatortest.com points to /vagrant/web, so this has to exist.

- sudo ./test/temp/bin/provision
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Genesis WordPress
=================
# Genesis WordPress

[![Build Status](https://travis-ci.org/genesis/wordpress.png)](https://travis-ci.org/genesis/wordpress)


> Rapidly create, develop, & deploy WordPress across multiple environments.
> ![Genesis WordPress Demo](demo.gif)
Expand Down
4 changes: 3 additions & 1 deletion generator/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var WordpressGenerator = function(args, options, config) {
}.bind(this)
});
});

this.sourceRoot(path.join(__dirname, 'templates'));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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'));
};
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More informative than the default "dot" reporter.

},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions provisioning/roles/common/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
system_packages:
- build-essential
- autoconf
- tasksel
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
31 changes: 31 additions & 0 deletions test/generator.js
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();
});
});
});
47 changes: 47 additions & 0 deletions test/site.install.js
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)
;
})
});
});
6 changes: 6 additions & 0 deletions test/support/generate
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();
60 changes: 60 additions & 0 deletions test/support/generator.js
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;