Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
longseespace committed Dec 2, 2015
1 parent 2af22ec commit a4c81c9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
76 changes: 38 additions & 38 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('underscore.string');
var mkdirp = require('mkdirp')
var mkdirp = require('mkdirp');

var AndroidGradleGenerator = yeoman.generators.Base.extend({

prompting: function () {
var done = this.async();

// Have Yeoman greet the user.
this.log(yosay('This generator will allow you to create a minimal '+chalk.magenta('InAiR')+' project with Gradle support.'));
this.log(yosay('This generator will allow you to create a minimal ' + chalk.magenta('InAiR') + ' project with Gradle support.'));

var prompts = [{
type: 'input',
Expand Down Expand Up @@ -43,51 +43,51 @@ var AndroidGradleGenerator = yeoman.generators.Base.extend({
},

app: function () {
var _appDir = [
var appDir = [
this.projectName,
this.projectName+'/app',
this.projectName+'/app/libs',
this.projectName+'/app/src',
this.projectName+'/app/src/androidTest',
this.projectName+'/app/src/androidTest/java',
this.projectName+'/app/src/main',
this.projectName+'/app/src/main/java',
this.projectName+'/app/src/main/res',
this.projectName+'/app/src/main/res/drawable',
this.projectName+'/app/src/main/res/layout',
this.projectName+'/app/src/main/res/values',
this.projectName+'/app/src/test',
this.projectName+'/app/src/test/java'
this.projectName + '/app',
this.projectName + '/app/libs',
this.projectName + '/app/src',
this.projectName + '/app/src/androidTest',
this.projectName + '/app/src/androidTest/java',
this.projectName + '/app/src/main',
this.projectName + '/app/src/main/java',
this.projectName + '/app/src/main/res',
this.projectName + '/app/src/main/res/drawable',
this.projectName + '/app/src/main/res/layout',
this.projectName + '/app/src/main/res/values',
this.projectName + '/app/src/test',
this.projectName + '/app/src/test/java'
];

this.log('\n' + chalk.green('Creating ') + 'project directories:');
var _appDirLength = _appDir.length;
var appDirLength = appDir.length;

for (var idx = 0; idx < _appDirLength; idx++) {
mkdirp(_appDir[idx]);
this.log('\t' + chalk.green('create ') + _appDir[idx]);
for (var idx = 0; idx < appDirLength; idx++) {
mkdirp(appDir[idx]);
this.log('\t' + chalk.green('create ') + appDir[idx]);
}

this.directory('gradle', this.projectName+'/gradle');
this.log('\t' + chalk.green('create ') + this.projectName+'/gradle');
this.directory('gradle', this.projectName + '/gradle');
this.log('\t' + chalk.green('create ') + this.projectName + '/gradle');

this.directory('inair', this.projectName+'/inair');
this.log('\t' + chalk.green('create ') + this.projectName+'/inair');
this.directory('inair', this.projectName + '/inair');
this.log('\t' + chalk.green('create ') + this.projectName + '/inair');
},

end: function () {
this.log("\n");
this.log("Finished creating your " + chalk.red.bold(this.appName) + " InAiR+Gradle application.");
this.log("Please update the " + chalk.yellow.bold('local.properties') + " with the Android SDK path");
this.log("\nOpen your favorite IDE and have fun building your next great app.");
this.log("\n");
},
this.log('\n');
this.log('Finished creating your ' + chalk.red.bold(this.appName) + ' InAiR+Gradle application.');
this.log('Please update the ' + chalk.yellow.bold('local.properties') + ' with the Android SDK path');
this.log('\nOpen your favorite IDE and have fun building your next great app.');
this.log('\n');
}
});

module.exports = AndroidGradleGenerator;

AndroidGradleGenerator.prototype.workspaceFiles = function workspaceFiles() {
var _configs = [
var configs = [
'build.gradle',
'gradle.properties',
'gradlew',
Expand All @@ -96,21 +96,21 @@ AndroidGradleGenerator.prototype.workspaceFiles = function workspaceFiles() {
'settings.gradle'
];

var _configLength = _configs.length;
var configLength = configs.length;

for (var idx = 0; idx < _configLength; idx++) {
this.template(_configs[idx], this.projectName+'/'+_configs[idx]);
for (var idx = 0; idx < configLength; idx++) {
this.template(configs[idx], this.projectName + '/' + configs[idx]);
}

this.template('gitignore', this.projectName+'/.gitignore');
this.template('gitignore', this.projectName + '/.gitignore');
};

AndroidGradleGenerator.prototype.androidSrcFiles = function androidSrcFiles() {
this.log('\n' + chalk.green('Creating ') + 'app files:');

this.template('app/build.gradle', this.projectName+'/app/build.gradle');
this.template('app/proguard-rules.pro', this.projectName+'/app/proguard-rules.pro');
this.directory('app/libs', this.projectName+'/app/libs');
this.template('app/build.gradle', this.projectName + '/app/build.gradle');
this.template('app/proguard-rules.pro', this.projectName + '/app/proguard-rules.pro');
this.directory('app/libs', this.projectName + '/app/libs');

var androidTestDir = this.projectName + '/app/src/androidTest/java/' + this.packageFolder;
this.template('app/src/androidTest/java/ApplicationTest.java', androidTestDir + '/ApplicationTest.java');
Expand Down
10 changes: 7 additions & 3 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ var helpers = require('yeoman-generator').test;
describe('generator-inair-blankapp:app', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({someOption: true})
.withPrompts({someAnswer: true})
.withPrompts({
appName: 'TestApp',
packageName: 'inair.test'
})
.on('end', done);
});

it('creates files', function () {
assert.file([
'dummyfile.txt'
'TestApp/.gitignore',
'TestApp/build.gradle',
'TestApp/settings.gradle'
]);
});
});

0 comments on commit a4c81c9

Please sign in to comment.