Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
removed unnecessary class suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarbara authored and revathskumar committed Feb 26, 2014
1 parent 02758c5 commit dba914a
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 100 deletions.
4 changes: 2 additions & 2 deletions templates/coffeescript/collection.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';

class <%= _.camelize(appname) %>.Collections.<%= _.classify(name) %>Collection extends Backbone.Collection
model: <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>Model
class <%= _.camelize(appname) %>.Collections.<%= _.classify(name) %> extends Backbone.Collection
model: <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>
2 changes: 1 addition & 1 deletion templates/coffeescript/model.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

class <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>Model extends Backbone.Model
class <%= _.camelize(appname) %>.Models.<%= _.classify(name) %> extends Backbone.Model
url: '',

initialize: () ->
Expand Down
2 changes: 1 addition & 1 deletion templates/coffeescript/router.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

class <%= _.camelize(appname) %>.Routers.<%= _.classify(name) %>Router extends Backbone.Router
class <%= _.camelize(appname) %>.Routers.<%= _.classify(name) %> extends Backbone.Router
2 changes: 1 addition & 1 deletion templates/coffeescript/view.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

class <%= _.camelize(appname) %>.Views.<%= _.classify(name) %>View extends Backbone.View
class <%= _.camelize(appname) %>.Views.<%= _.classify(name) %> extends Backbone.View

template: JST['<%= jst_path %>']

Expand Down
4 changes: 2 additions & 2 deletions templates/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
(function () {
'use strict';

<%= _.camelize(appname) %>.Collections.<%= _.classify(name) %>Collection = Backbone.Collection.extend({
<%= _.camelize(appname) %>.Collections.<%= _.classify(name) %> = Backbone.Collection.extend({

model: <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>Model
model: <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>

});

Expand Down
2 changes: 1 addition & 1 deletion templates/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function () {
'use strict';

<%= _.camelize(appname) %>.Models.<%= _.classify(name) %>Model = Backbone.Model.extend({
<%= _.camelize(appname) %>.Models.<%= _.classify(name) %> = Backbone.Model.extend({

url: '',

Expand Down
2 changes: 1 addition & 1 deletion templates/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function () {
'use strict';

<%= _.camelize(appname) %>.Routers.<%= _.classify(name) %>Router = Backbone.Router.extend({
<%= _.camelize(appname) %>.Routers.<%= _.classify(name) %> = Backbone.Router.extend({

});

Expand Down
2 changes: 1 addition & 1 deletion templates/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function () {
'use strict';

<%= _.camelize(appname) %>.Views.<%= _.classify(name) %>View = Backbone.View.extend({
<%= _.camelize(appname) %>.Views.<%= _.classify(name) %> = Backbone.View.extend({

template: JST['<%= jst_path %>'],

Expand Down
79 changes: 42 additions & 37 deletions test/test-apppath.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
/* global describe, beforeEach, it */
/*global describe:true, beforeEach:true, it:true */
'use strict';
var path = require('path');
var path = require('path');
var helpers = require('yeoman-generator').test;
var fs = require('fs');
var assert = require('assert');
var fs = require('fs');

describe('backbone generator with appPath option', function () {
beforeEach(function (done) {
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
helpers.testDirectory(path.join(__dirname, './temp'), function (err) {
if (err) {
return done(err);
}

this.app = helpers.createGenerator('backbone:app', [
this.backbone = {};
this.backbone.app = helpers.createGenerator('backbone:app', [
'../../app', [
helpers.createDummyGenerator(), 'mocha:app'
helpers.createDummyGenerator(),
'mocha:app'
]
], ['temp'], {appPath: 'public', 'skip-install': true});
], ['temp'], {appPath: 'public'});
this.backbone.app.options['skip-install'] = true;

helpers.mockPrompt(this.app, {
helpers.mockPrompt(this.backbone.app, {
features: ['compassBootstrap']
});

var out = [
'{',
' "generator-backbone": {',
' "appPath": "public"',
' "appPath": "public",',
' "appName": "Temp"',
' }',
'}'
];
Expand All @@ -37,10 +41,9 @@ describe('backbone generator with appPath option', function () {
describe('create expected files', function () {
it('in path specified by --appPath', function (done) {
var expected = [
// add files you expect to exist here.
['Gruntfile.js', /app: 'public'/],
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/],
['Gruntfile.js', /app: 'public'/],
'public/404.html',
'public/favicon.ico',
'public/robots.txt',
Expand All @@ -51,75 +54,77 @@ describe('backbone generator with appPath option', function () {
'.bowerrc',
'.jshintrc',
'.editorconfig',
'Gruntfile.js',
'package.json',
'.yo-rc.json',
'public/scripts/main.js',
'public/styles/main.scss'
];

this.app.run({}, function () {
this.backbone.app.run({}, function () {
helpers.assertFiles(expected);
done();
});
});
});

describe('creates sub generators', function () {

it('backbone model', function (done) {
describe('Backbone Model', function () {
it('creates backbone model', function (done) {
var model = helpers.createGenerator('backbone:model', ['../../model'], ['foo']);

this.app.run({}, function () {
this.backbone.app.run({}, function () {
model.run([], function () {
helpers.assertFiles([
['public/scripts/models/foo.js',
/Models.FooModel = Backbone.Model.extend\(\{/]
['public/scripts/models/foo.js', /Models.Foo = Backbone.Model.extend\(\{/]
]);
});
done();
});
});
});

it('backbone router', function (done) {
var router = helpers.createGenerator('backbone:router', ['../../router'], ['foo']);
describe('Backbone Collection', function () {
it('creates backbone collection', function (done) {
var collection = helpers.createGenerator('backbone:collection', ['../../collection'], ['foo']);

this.app.run({}, function () {
router.run([], function () {
this.backbone.app.run({}, function () {
collection.run([], function () {
helpers.assertFiles([
['public/scripts/routes/foo.js', /Routers.FooRouter = Backbone.Router.extend\(\{/]
['public/scripts/collections/foo.js', /Collections.Foo = Backbone.Collection.extend\(\{/]
]);
});
done();
});
});
});

it('backbone collection', function (done) {
var collection = helpers.createGenerator('backbone:collection', ['../../collection'], ['foo']);
describe('Backbone Router', function () {
it('creates backbone router', function (done) {
var router = helpers.createGenerator('backbone:router', ['../../router'], ['foo']);

this.app.run({}, function () {
collection.run([], function () {
this.backbone.app.run({}, function () {
router.run([], function () {
helpers.assertFiles([
['public/scripts/collections/foo.js', /Collections.FooCollection = Backbone.Collection.extend\(\{/]
['public/scripts/routes/foo.js', /Routers.Foo = Backbone.Router.extend\(\{/]
]);
});
done();
});
});
});

it('backbone view', function (done) {
var view = helpers.createGenerator('backbone:view', [
'../../view'
], ['foo']);
describe('Backbone View', function () {
it('creates backbone view', function (done) {
var view = helpers.createGenerator('backbone:view', ['../../view'], ['foo']);

this.app.run({}, function () {
this.backbone.app.run({}, function () {
view.run([], function () {
helpers.assertFiles([
['public/scripts/views/foo.js', /Views.FooView = Backbone.View.extend\(\{(.|\n)*public\/scripts\/templates\/foo.ejs/],
['public/scripts/views/foo.js', /Views.Foo = Backbone.View.extend\(\{(.|\n)*public\/scripts\/templates\/foo.ejs/],
'public/scripts/templates/foo.ejs'
]);
});
done();
});
});
});

});
6 changes: 4 additions & 2 deletions test/test-coffee-requirejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('Backbone generator test with --coffee and --requirejs option', functio
var out = [
'{',
' "generator-backbone": {',
' "appPath": "app"',
' "appPath": "app",',
' "appName": "Temp"',
' }',
'}'
];
Expand All @@ -52,7 +53,7 @@ describe('Backbone generator test with --coffee and --requirejs option', functio
'.bowerrc',
'.jshintrc',
'.editorconfig',
'package.json',
'.yo-rc.json',
'app/scripts/main.coffee'
];

Expand Down Expand Up @@ -126,4 +127,5 @@ describe('Backbone generator test with --coffee and --requirejs option', functio
});
});
});

});
18 changes: 11 additions & 7 deletions test/test-coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('Backbone generator test with --coffee option', function () {
var out = [
'{',
' "generator-backbone": {',
' "appPath": "app"',
' "appPath": "app",',
' "appName": "Temp"',
' }',
'}'
];
Expand All @@ -52,8 +53,8 @@ describe('Backbone generator test with --coffee option', function () {
'.bowerrc',
'.jshintrc',
'.editorconfig',
'package.json',
'app/scripts/main.coffee',
'.yo-rc.json',
'app/scripts/main.coffee'
];

this.backbone.app.run([], function () {
Expand All @@ -65,6 +66,7 @@ describe('Backbone generator test with --coffee option', function () {

describe('Backbone Model in coffeescript', function () {
it('creates backbone model', function (done) {
var model = helpers.createGenerator('backbone:model', ['../../model'], ['foo']);

this.backbone.app.run([], function () {
var model = helpers.createGenerator('backbone:model', [
Expand All @@ -73,9 +75,10 @@ describe('Backbone generator test with --coffee option', function () {
'backbone-mocha:model'
]
], ['foo']);

model.run([], function () {
helpers.assertFiles([
['app/scripts/models/foo.coffee', /class temp.Models.FooModel extends Backbone.Model/]
['app/scripts/models/foo.coffee', /class Temp.Models.Foo extends Backbone.Model/]
]);
});
done();
Expand All @@ -96,7 +99,7 @@ describe('Backbone generator test with --coffee option', function () {

collection.run([], function () {
helpers.assertFiles([
['app/scripts/collections/foo.coffee', /class temp.Collections.FooCollection extends Backbone.Collection/]
['app/scripts/collections/foo.coffee', /class Temp.Collections.Foo extends Backbone.Collection/]
]);
});
done();
Expand All @@ -117,7 +120,7 @@ describe('Backbone generator test with --coffee option', function () {

router.run([], function () {
helpers.assertFiles([
['app/scripts/routes/foo.coffee', /class temp.Routers.FooRouter extends Backbone.Router/]
['app/scripts/routes/foo.coffee', /class Temp.Routers.Foo extends Backbone.Router/]
]);
});
done();
Expand All @@ -138,12 +141,13 @@ describe('Backbone generator test with --coffee option', function () {

view.run([], function () {
helpers.assertFiles([
['app/scripts/views/foo.coffee', /class temp.Views.FooView extends Backbone.View/],
['app/scripts/views/foo.coffee', /class Temp.Views.Foo extends Backbone.View/],
'app/scripts/templates/foo.ejs'
]);
});
done();
});
});
});

});
Loading

0 comments on commit dba914a

Please sign in to comment.