Skip to content

Loading…

Refined specs and running environment #3

Closed
wants to merge 1 commit into from

2 participants

@cloudchen

[+] Specs run on standalone server instead of file:// protocol
[*] Modified being tested source file to be more frinendly for requirejs user

@cloudchen cloudchen Refined specs and running environment
[+] Specs run on standalone server instead of file:// protocol
[*] Modified being tested source file to be more frinendly for requirejs user
784bcf3
@cloudchen cloudchen commented on the diff
package.json
@@ -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",

Using my own copy to get rid of absolute path issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maenu maenu added a commit that referenced this pull request
@maenu merge connect example from @cloudchen #3 80325ed
@maenu
Owner

The path issue should be resolved in the template version 0.2.1.

I split your commit in two and could not directly merge the whole pull request, since I would like to keep the showcase of different features apart. The updated requirejs example landed on the requirejs branch, the ad-hoc server example on the connect branch.

In case I forgot something let me know, otherwise you can close.

@maenu
Owner

Ok, I'll close ;).

@maenu maenu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 29, 2013
  1. @cloudchen

    Refined specs and running environment

    cloudchen committed
    [+] Specs run on standalone server instead of file:// protocol
    [*] Modified being tested source file to be more frinendly for requirejs user
Showing with 40 additions and 20 deletions.
  1. +9 −4 Gruntfile.js
  2. +4 −3 package.json
  3. +8 −0 src/main/js/Enum.js
  4. +7 −5 src/main/js/Generator.js
  5. +12 −8 src/test/js/Generator.js
View
13 Gruntfile.js
@@ -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',
@@ -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']);
+};
View
7 package.json
@@ -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",

Using my own copy to get rid of absolute path issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ "grunt-contrib-connect": "~0.2.0",
"grunt-template-jasmine-requirejs": "~0.1.0"
}
}
View
8 src/main/js/Enum.js
@@ -0,0 +1,8 @@
+define({
+ ONE: '.',
+ TWO: ':',
+ THREE: ':.',
+ FOUR: '::',
+ FIVE: ':.:',
+ SIX: ':::'
+});
View
12 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;
+ };
+ };
+});
View
20 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);
+ });
+ });
+ });
+});
Something went wrong with that request. Please try again.