Skip to content
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

Refined specs and running environment #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions Gruntfile.js
Expand Up @@ -4,17 +4,21 @@ module.exports = function(grunt) {
package: grunt.file.readJSON('package.json'),
src: {
main: 'src/main',
test: 'src/test',
test: 'src/test'
},
bin: {
coverage: 'bin/coverage'
}
},
connect: {
default_options: {}
},
jasmine: {
coverage: {
src: '<%= meta.src.main %>/js/Generator.js',
src: '<%= meta.src.main %>/js/*.js',
options: {
specs: '<%= meta.src.test %>/js/Generator.js',
host: 'http://127.0.0.1:8000/',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: '<%= meta.bin.coverage %>/coverage.json',
Expand Down Expand Up @@ -45,6 +49,7 @@ module.exports = function(grunt) {
});

grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-connect');

grunt.registerTask('test:coverage', ['jasmine:coverage']);
};
grunt.registerTask('test:coverage', ['connect', 'jasmine:coverage']);
};
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -9,9 +9,10 @@
"url": "https://github.com/maenu/grunt-template-jasmine-istanbul-example.git"
},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-jasmine": "~0.3.1",
"grunt-template-jasmine-istanbul": "~0.2.0",
"grunt": "~0.4.1",
"grunt-contrib-jasmine": "~0.4.1",
"grunt-template-jasmine-istanbul": "git://github.com/cloudchen/grunt-template-jasmine-istanbul",
Copy link
Author

Choose a reason for hiding this comment

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

Using my own copy to get rid of absolute path issue

"grunt-contrib-connect": "~0.2.0",
"grunt-template-jasmine-requirejs": "~0.1.0"
}
}
8 changes: 8 additions & 0 deletions src/main/js/Enum.js
@@ -0,0 +1,8 @@
define({
ONE: '.',
TWO: ':',
THREE: ':.',
FOUR: '::',
FIVE: ':.:',
SIX: ':::'
});
12 changes: 7 additions & 5 deletions src/main/js/Generator.js
@@ -1,5 +1,7 @@
define({
getRandomNumber: function () {
return 4;
}
});
define(['Enum'], function(Enum) {
return function (){
this.getRandomNumber = function() {
return Enum.FOUR;
};
};
});
20 changes: 12 additions & 8 deletions src/test/js/Generator.js
@@ -1,9 +1,13 @@
var Generator = require('Generator');
define(['Generator', 'Enum'], function(Generator, Enum) {
describe('Generator', function () {
beforeEach(function() {
this.generator = new Generator();
});

describe('Generator', function () {
describe('getRandomNumber', function () {
it('should be chosen by fair dice roll', function () {
expect(Generator.getRandomNumber()).toBe(4);
});
});
});
describe('getRandomNumber', function () {
it('should be chosen by fair dice roll', function () {
expect(this.generator.getRandomNumber()).toBe(Enum.FOUR);
});
});
});
});