Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Awk34 committed Aug 27, 2015
2 parents 5eb3bb0 + d3fa78c commit 180dc63
Show file tree
Hide file tree
Showing 27 changed files with 135 additions and 143 deletions.
15 changes: 6 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({

this.filters = {};

// dynamic assertion statement
this.does = this.is = function(foo) {
foo = this.engine(foo.replace(/\(;>%%<;\)/g, '<%')
.replace(/\(;>%<;\)/g, '%>'), this);
if (this.filters.should) {
return foo + '.should';
} else {
return 'expect(' + foo + ').to';
}
// dynamic assertion statements
this.expect = function() {
return this.filters.expect ? 'expect(' : '';
}.bind(this);
this.to = function() {
return this.filters.expect ? ').to' : '.should';
}.bind(this);
},

Expand Down
4 changes: 2 additions & 2 deletions app/templates/client/app/account(auth)/login/login(html).html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div class="row">
<div class="col-sm-12">
<h1>Login</h1>
<p>Accounts are reset on server restart from <code>server/config/seed.js</code>. Default account is <code>test@test.com</code> / <code>test</code></p>
<p>Admin account is <code>admin@admin.com</code> / <code>admin</code></p>
<p>Accounts are reset on server restart from <code>server/config/seed.js</code>. Default account is <code>test@example.com</code> / <code>test</code></p>
<p>Admin account is <code>admin@example.com</code> / <code>admin</code></p>
</div>
<div class="col-sm-12">
<form class="form" name="form" ng-submit="login(form)" novalidate>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/client/app/account(auth)/login/login(jade).jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ navbar
| Accounts are reset on server restart from
code server/config/seed.js
| . Default account is
code test@test.com
code test@example.com
| /
code test
p
| Admin account is
code admin@admin.com
code admin@example.com
| /
code admin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
angular.module '<%= scriptAppName %>'
.controller 'AdminCtrl', ($scope, $http, Auth, User) ->

$http.get '/api/users'
.success (users) ->
$scope.users = users
$scope.users = User.query()

$scope.delete = (user) ->
User.remove id: user._id
Expand Down
4 changes: 2 additions & 2 deletions app/templates/client/app/main/main.controller(coffee).coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ angular.module '<%= scriptAppName %>'
.controller 'MainCtrl', ($scope, $http<% if (filters.socketio) { %>, socket<% } %>) ->
$scope.awesomeThings = []

$http.get('/api/things').success (awesomeThings) ->
$scope.awesomeThings = awesomeThings
$http.get('/api/things').then (response) ->
$scope.awesomeThings = response.data
<% if (filters.socketio) { %>socket.syncUpdates 'thing', $scope.awesomeThings<% } %>
<% if (filters.models) { %>
$scope.addThing = ->
Expand Down
4 changes: 2 additions & 2 deletions app/templates/client/app/main/main.controller(js).js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ angular.module('<%= scriptAppName %>')
.controller('MainCtrl', function($scope, $http<% if (filters.socketio) { %>, socket<% } %>) {
$scope.awesomeThings = [];

$http.get('/api/things').success(function(awesomeThings) {
$scope.awesomeThings = awesomeThings;<% if (filters.socketio) { %>
$http.get('/api/things').then(function(response) {
$scope.awesomeThings = response.data;<% if (filters.socketio) { %>
socket.syncUpdates('thing', $scope.awesomeThings);<% } %>
});
<% if (filters.models) { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ describe 'Controller: MainCtrl', ->
it 'should attach a list of things to the scope', ->
$httpBackend.flush()<% if (filters.jasmine) { %>
expect(scope.awesomeThings.length).toBe 4 <% } if (filters.mocha) { %>
<%= does("scope.awesomeThings.length") %>.equal 4<% } %>
<%= expect() %>scope.awesomeThings.length<%= to() %>.equal 4<% } %>
2 changes: 1 addition & 1 deletion app/templates/client/app/main/main.controller.spec(js).js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('Controller: MainCtrl', function() {
it('should attach a list of things to the scope', function() {
$httpBackend.flush();<% if (filters.jasmine) { %>
expect(scope.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %>
<%= does("scope.awesomeThings.length") %>.equal(4);<% } %>
<%= expect() %>scope.awesomeThings.length<%= to() %>.equal(4);<% } %>
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ angular.module('<%= scriptAppName %>')
id:'me'
}
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Login View', function() {

var testUser = {
name: 'Test User',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand Down
22 changes: 11 additions & 11 deletions app/templates/e2e/account(auth)/login/login.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Login View', function() {

var testUser = {
name: 'Test User',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand All @@ -35,12 +35,12 @@ describe('Login View', function() {
});

it('should include login form with correct inputs and submit button', function() {
<%= does("page.form.email.getAttribute('type')") %>.eventually.equal('email');
<%= does("page.form.email.getAttribute('name')") %>.eventually.equal('email');
<%= does("page.form.password.getAttribute('type')") %>.eventually.equal('password');
<%= does("page.form.password.getAttribute('name')") %>.eventually.equal('password');
<%= does("page.form.submit.getAttribute('type')") %>.eventually.equal('submit');
<%= does("page.form.submit.getText()") %>.eventually.equal('Login');
<%= expect() %>page.form.email.getAttribute('type')<%= to() %>.eventually.equal('email');
<%= expect() %>page.form.email.getAttribute('name')<%= to() %>.eventually.equal('email');
<%= expect() %>page.form.password.getAttribute('type')<%= to() %>.eventually.equal('password');
<%= expect() %>page.form.password.getAttribute('name')<%= to() %>.eventually.equal('password');
<%= expect() %>page.form.submit.getAttribute('type')<%= to() %>.eventually.equal('submit');
<%= expect() %>page.form.submit.getText()<%= to() %>.eventually.equal('Login');
});

describe('with local auth', function() {
Expand All @@ -50,8 +50,8 @@ describe('Login View', function() {

var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
<%= expect() %>navbar.navbarAccountGreeting.getText()<%= to() %>.eventually.equal('Hello ' + testUser.name);
});

describe('and invalid credentials', function() {
Expand All @@ -65,10 +65,10 @@ describe('Login View', function() {
password: 'badPassword'
});

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/login');
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/login');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
<%= does("helpBlock.getText()") %>.eventually.equal('This password is not correct.');
<%= expect() %>helpBlock.getText()<%= to() %>.eventually.equal('This password is not correct.');
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Logout View', function() {

var testUser = {
name: 'Test User',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand Down
10 changes: 5 additions & 5 deletions app/templates/e2e/account(auth)/logout/logout.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Logout View', function() {

var testUser = {
name: 'Test User',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand All @@ -39,15 +39,15 @@ describe('Logout View', function() {
it('should logout a user and redirecting to "/"', function() {
var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
<%= expect() %>navbar.navbarAccountGreeting.getText()<%= to() %>.eventually.equal('Hello ' + testUser.name);

browser.get(config.baseUrl + '/logout');

navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.isDisplayed()") %>.eventually.equal(false);
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
<%= expect() %>navbar.navbarAccountGreeting.isDisplayed()<%= to() %>.eventually.equal(false);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Signup View', function() {

var testUser = {
name: 'Test',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand Down
28 changes: 14 additions & 14 deletions app/templates/e2e/account(auth)/signup/signup.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Signup View', function() {

var testUser = {
name: 'Test',
email: 'test@test.com',
email: 'test@example.com',
password: 'test'
};

Expand All @@ -29,14 +29,14 @@ describe('Signup View', function() {
});

it('should include signup form with correct inputs and submit button', function() {
<%= does("page.form.name.getAttribute('type')") %>.eventually.equal('text');
<%= does("page.form.name.getAttribute('name')") %>.eventually.equal('name');
<%= does("page.form.email.getAttribute('type')") %>.eventually.equal('email');
<%= does("page.form.email.getAttribute('name')") %>.eventually.equal('email');
<%= does("page.form.password.getAttribute('type')") %>.eventually.equal('password');
<%= does("page.form.password.getAttribute('name')") %>.eventually.equal('password');
<%= does("page.form.submit.getAttribute('type')") %>.eventually.equal('submit');
<%= does("page.form.submit.getText()") %>.eventually.equal('Sign up');
<%= expect() %>page.form.name.getAttribute('type')<%= to() %>.eventually.equal('text');
<%= expect() %>page.form.name.getAttribute('name')<%= to() %>.eventually.equal('name');
<%= expect() %>page.form.email.getAttribute('type')<%= to() %>.eventually.equal('email');
<%= expect() %>page.form.email.getAttribute('name')<%= to() %>.eventually.equal('email');
<%= expect() %>page.form.password.getAttribute('type')<%= to() %>.eventually.equal('password');
<%= expect() %>page.form.password.getAttribute('name')<%= to() %>.eventually.equal('password');
<%= expect() %>page.form.submit.getAttribute('type')<%= to() %>.eventually.equal('submit');
<%= expect() %>page.form.submit.getText()<%= to() %>.eventually.equal('Sign up');
});

describe('with local auth', function() {
Expand All @@ -51,8 +51,8 @@ describe('Signup View', function() {

var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
<%= expect() %>navbar.navbarAccountGreeting.getText()<%= to() %>.eventually.equal('Hello ' + testUser.name);
});

describe('and invalid credentials', function() {
Expand All @@ -63,11 +63,11 @@ describe('Signup View', function() {
it('should indicate signup failures', function() {
page.signup(testUser);

<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/signup');
<%= does("page.form.email.getAttribute('class')") %>.eventually.contain('ng-invalid-mongoose');
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/signup');
<%= expect() %>page.form.email.getAttribute('class')<%= to() %>.eventually.contain('ng-invalid-mongoose');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
<%= does("helpBlock.getText()") %>.eventually.equal('The specified email address is already in use.');
<%= expect() %>helpBlock.getText()<%= to() %>.eventually.equal('The specified email address is already in use.');
});

});
Expand Down
6 changes: 3 additions & 3 deletions app/templates/e2e/main/main.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('Main View', function() {
});

it('should include jumbotron with correct data', function() {
<%= does("page.h1El.getText()") %>.eventually.equal('\'Allo, \'Allo!');
<%= does("page.imgEl.getAttribute('src')") %>.eventually.match(/yeoman.png$/);
<%= does("page.imgEl.getAttribute('alt')") %>.eventually.equal('I\'m Yeoman');
<%= expect() %>page.h1El.getText()<%= to() %>.eventually.equal('\'Allo, \'Allo!');
<%= expect() %>page.imgEl.getAttribute('src')<%= to() %>.eventually.match(/yeoman.png$/);
<%= expect() %>page.imgEl.getAttribute('alt')<%= to() %>.eventually.equal('I\'m Yeoman');
});
});
38 changes: 19 additions & 19 deletions app/templates/server/api/user(auth)/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,65 +41,65 @@ var userIndex = proxyquire('./index', {
describe('User API Router:', function() {

it('should return an express router instance', function() {
userIndex.should.equal(routerStub);
<%= expect() %>userIndex<%= to() %>.equal(routerStub);
});

describe('GET /api/users', function() {

it('should verify admin role and route to user.controller.index', function() {
routerStub.get
.withArgs('/', 'authService.hasRole.admin', 'userCtrl.index')
.should.have.been.calledOnce;
<%= expect() %>routerStub.get
.withArgs('/', 'authService.hasRole.admin', 'userCtrl.index')
<%= to() %>.have.been.calledOnce;
});

});

describe('DELETE /api/users/:id', function() {

it('should verify admin role and route to user.controller.destroy', function() {
routerStub.delete
.withArgs('/:id', 'authService.hasRole.admin', 'userCtrl.destroy')
.should.have.been.calledOnce;
<%= expect() %>routerStub.delete
.withArgs('/:id', 'authService.hasRole.admin', 'userCtrl.destroy')
<%= to() %>.have.been.calledOnce;
});

});

describe('GET /api/users/me', function() {

it('should be authenticated and route to user.controller.me', function() {
routerStub.get
.withArgs('/me', 'authService.isAuthenticated', 'userCtrl.me')
.should.have.been.calledOnce;
<%= expect() %>routerStub.get
.withArgs('/me', 'authService.isAuthenticated', 'userCtrl.me')
<%= to() %>.have.been.calledOnce;
});

});

describe('PUT /api/users/:id/password', function() {

it('should be authenticated and route to user.controller.changePassword', function() {
routerStub.put
.withArgs('/:id/password', 'authService.isAuthenticated', 'userCtrl.changePassword')
.should.have.been.calledOnce;
<%= expect() %>routerStub.put
.withArgs('/:id/password', 'authService.isAuthenticated', 'userCtrl.changePassword')
<%= to() %>.have.been.calledOnce;
});

});

describe('GET /api/users/:id', function() {

it('should be authenticated and route to user.controller.show', function() {
routerStub.get
.withArgs('/:id', 'authService.isAuthenticated', 'userCtrl.show')
.should.have.been.calledOnce;
<%= expect() %>routerStub.get
.withArgs('/:id', 'authService.isAuthenticated', 'userCtrl.show')
<%= to() %>.have.been.calledOnce;
});

});

describe('POST /api/users', function() {

it('should route to user.controller.create', function() {
routerStub.post
.withArgs('/', 'userCtrl.create')
.should.have.been.calledOnce;
<%= expect() %>routerStub.post
.withArgs('/', 'userCtrl.create')
<%= to() %>.have.been.calledOnce;
});

});
Expand Down
6 changes: 3 additions & 3 deletions app/templates/server/api/user(auth)/user.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('User API:', function() {
<% if (filters.mongooseModels) { %>user = new User({<% }
if (filters.sequelizeModels) { %>user = User.build({<% } %>
name: 'Fake User',
email: 'test@test.com',
email: 'test@example.com',
password: 'password'
});

Expand All @@ -37,7 +37,7 @@ describe('User API:', function() {
request(app)
.post('/auth/local')
.send({
email: 'test@test.com',
email: 'test@example.com',
password: 'password'
})
.expect(200)
Expand All @@ -55,7 +55,7 @@ describe('User API:', function() {
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
res.body._id.toString().should.equal(user._id.toString());
<%= expect() %>res.body._id.toString()<%= to() %>.equal(user._id.toString());
done();
});
});
Expand Down

0 comments on commit 180dc63

Please sign in to comment.