spec-detective
Advanced tools
Comparing version 0.0.3 to 0.0.4
module.exports = function (grunt) { | ||
'use strict'; | ||
'use strict'; | ||
grunt.loadNpmTasks('grunt-jslint'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.loadNpmTasks('grunt-jslint'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.initConfig({ | ||
jslint: { | ||
source: { | ||
src: ['index.js'], | ||
options: { | ||
failOnError: true | ||
grunt.initConfig({ | ||
jslint: { | ||
source: { | ||
src: ['index.js'], | ||
options: { | ||
failOnError: true | ||
}, | ||
directives: {} | ||
} | ||
}, | ||
directives: {} | ||
} | ||
}, | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: 'spec' | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: 'spec' | ||
}, | ||
src: ['test/**/*.js'] | ||
} | ||
}, | ||
src: ['test/**/*.js'] | ||
} | ||
} | ||
}); | ||
watch: { | ||
scripts: { | ||
files: ['lib/*.js', 'test/**/*.js'], | ||
tasks: ['test'] | ||
} | ||
} | ||
}); | ||
grunt.registerTask('default', ['jslint', 'mochaTest']); | ||
grunt.registerTask('test', ['mochaTest']); | ||
grunt.registerTask('default', ['jslint', 'mochaTest']); | ||
grunt.registerTask('test', ['mochaTest']); | ||
} |
@@ -25,10 +25,12 @@ var ParserFactory = require('./parserFactory'); | ||
var current = output, | ||
i; | ||
for (i = 0; i < suite.length; i += 1) { | ||
if (current[suite[i]] === undefined) { | ||
current[suite[i]] = {}; | ||
} | ||
current = current[suite[i]]; | ||
key = suite.join(" "); | ||
if (key === "") { | ||
return current; | ||
} | ||
return current; | ||
if (current[key] === undefined) { | ||
current[key] = {}; | ||
} | ||
return current[key]; | ||
} | ||
@@ -35,0 +37,0 @@ |
@@ -45,5 +45,18 @@ var response; | ||
object = {}; | ||
object[currentDescription.join(' ')] = specValue; | ||
var lengthIndex = currentDescription.length - 1; | ||
suite = currentDescription.slice(0, (lengthIndex)).join(" "); | ||
spec = currentDescription[lengthIndex]; | ||
object = {}; | ||
if (suite === "") { | ||
object[spec] = specValue; | ||
} else { | ||
object[suite] = {}; | ||
object[suite][spec] = specValue; | ||
} | ||
if (typeof (specValue) !== 'undefined' && typeof (comparisonValue) !== 'undefined') { | ||
@@ -50,0 +63,0 @@ if (comparisonValue === "PASSED") { |
@@ -19,3 +19,4 @@ var lineReader = require('line-reader'); | ||
strip: function(line) { | ||
return this.match(line)[1].replace('it ', ''); | ||
var regex = new RegExp('(it )', 'gi' ); | ||
return this.match(line)[1].replace(regex, ''); | ||
} | ||
@@ -42,6 +43,6 @@ }, | ||
'SKIP' : { | ||
tokens: ['> skip'], | ||
tokens: ['> skip', '>skip'], | ||
match: function(line) { | ||
for(var i = 0; i < this.tokens.length; i++) { | ||
var regex = new RegExp('\\' + this.tokens[i] + '([^\n]*)'); | ||
var regex = new RegExp('\\' + this.tokens[i] + '([^\n]*)', 'i'); | ||
if(line.match(regex)) { | ||
@@ -54,3 +55,3 @@ return line.match(regex); | ||
} | ||
} | ||
}; | ||
@@ -57,0 +58,0 @@ |
@@ -25,9 +25,24 @@ var colors = require('colors'), | ||
var spec, | ||
line; | ||
for (i = 0; i < states.length; i += 1) { | ||
for(key in states[i]) { | ||
if (typeof states[i][key] === "string") { | ||
spec = key; | ||
line = states[i][key]; | ||
} else { | ||
for (suite in states[i][key]) { | ||
if (states[i][key].hasOwnProperty( suite )) { | ||
spec = key + " " + suite; | ||
line = states[i][key][suite]; | ||
} | ||
}; | ||
} | ||
callback( | ||
key[color] | ||
spec[color] | ||
); | ||
callback( | ||
states[i][key].grey | ||
line.grey | ||
); | ||
@@ -34,0 +49,0 @@ } |
{ | ||
"name": "spec-detective", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A cool way to find out if your spec's in feature files and the like have met expectations.", | ||
@@ -36,3 +36,3 @@ "main": "index.js", | ||
"grunt-cli": "~0.1.8", | ||
"grunt-contrib-watch": "~0.3.1", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-shell": "~0.2.2", | ||
@@ -47,3 +47,5 @@ "grunt-check-modules": "~0.2.0", | ||
"mockery": "~1.4.0", | ||
"sinon": "~1.9.0" | ||
"sinon": "~1.9.0", | ||
"xml2js": "~0.4.1", | ||
"xmlbuilder": "~2.1.0" | ||
}, | ||
@@ -54,4 +56,5 @@ "dependencies": { | ||
"glob": "~3.2.9", | ||
"jsonfile": "~1.1.1" | ||
"jsonfile": "~1.1.1", | ||
"xmlbuilder": "~2.1.0" | ||
} | ||
} |
@@ -32,7 +32,4 @@ var featureTransformer = require('../lib/featureTransformer'), | ||
var expectedOutput = { | ||
"a description" : { | ||
"another description" : { | ||
"should match 2 descriptions" : "test/fixtures/spec/twoDescribes.feature:3" | ||
} | ||
"a description another description" : { | ||
"should match 2 descriptions" : "test/fixtures/spec/twoDescribes.feature:3" | ||
} | ||
@@ -59,6 +56,4 @@ }; | ||
}, | ||
"second description" : { | ||
"nested description" : { | ||
"should do something else" : "test/fixtures/spec/full.feature:6" | ||
} | ||
"second description nested description" : { | ||
"should do something else" : "test/fixtures/spec/full.feature:6" | ||
} | ||
@@ -75,6 +70,4 @@ }; | ||
}, | ||
"second description" : { | ||
"nested description" : { | ||
"should do something else" : "test/fixtures/spec/fullNewlineDelimiter.feature:6" | ||
} | ||
"second description nested description" : { | ||
"should do something else" : "test/fixtures/spec/fullNewlineDelimiter.feature:6" | ||
} | ||
@@ -81,0 +74,0 @@ }; |
@@ -5,6 +5,4 @@ { | ||
}, | ||
"a description": { | ||
"another description": { | ||
"should match 2 descriptions": "test/fixtures/spec/twoDescribes.feature:3" | ||
} | ||
"a description another description": { | ||
"should match 2 descriptions": "test/fixtures/spec/twoDescribes.feature:3" | ||
}, | ||
@@ -15,6 +13,4 @@ "should do something": "test/fixtures/spec/exampleSpecLc.feature:1", | ||
}, | ||
"second description": { | ||
"nested description": { | ||
"should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6" | ||
} | ||
"second description nested description": { | ||
"should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6" | ||
}, | ||
@@ -21,0 +17,0 @@ "spec 1": "test/fixtures/spec/multiIt.feature:1", |
@@ -23,4 +23,4 @@ (function(require){ | ||
var expected = [ | ||
{"open description should do something": "test/fixtures/spec/closedDescribeNewline.feature:4"}, | ||
{"first description should do something": "test/fixtures/spec/fullNewlineDelimiter.feature:2"}, | ||
{"open description": {"should do something": "test/fixtures/spec/closedDescribeNewline.feature:4"}}, | ||
{"first description": {"should do something": "test/fixtures/spec/fullNewlineDelimiter.feature:2"}}, | ||
]; | ||
@@ -40,15 +40,11 @@ testResult = { | ||
var expected = [ | ||
{"a description another description should match 2 descriptions": "test/fixtures/spec/twoDescribes.feature:3"}, | ||
{"second description nested description should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6"}, | ||
{"a description another description": { "should match 2 descriptions": "test/fixtures/spec/twoDescribes.feature:3"}}, | ||
{"second description nested description": {"should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6"}}, | ||
]; | ||
testResult = { | ||
"a description": { | ||
"another description": { | ||
"should match 2 descriptions": "PASSED" | ||
} | ||
"a description another description": { | ||
"should match 2 descriptions": "PASSED" | ||
}, | ||
"second description": { | ||
"nested description": { | ||
"should do something else": "PASSED" | ||
} | ||
"second description nested description": { | ||
"should do something else": "PASSED" | ||
} | ||
@@ -61,10 +57,8 @@ }; | ||
var expected = [ | ||
{"second description nested description should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6"}, | ||
{"second description nested description":{"should do something else": "test/fixtures/spec/fullNewlineDelimiter.feature:6"}}, | ||
{"should only be displayed if the \"Live Page Cross Promo\" module is present.": "test/fixtures/spec/realSpec.feature:26"} | ||
]; | ||
testResult = { | ||
"second description": { | ||
"nested description": { | ||
"should do something else": "PASSED" | ||
} | ||
"second description nested description": { | ||
"should do something else": "PASSED" | ||
}, | ||
@@ -71,0 +65,0 @@ "should only be displayed if the \"Live Page Cross Promo\" module is present.": "PASSED", |
@@ -11,3 +11,5 @@ (function(require){ | ||
expected.passed = [{ | ||
"describe something should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
"describe something": { | ||
"should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
} | ||
}]; | ||
@@ -21,3 +23,5 @@ objectsEqual(inspector(filesContent()), expected); | ||
expected.pending = [{ | ||
"describe something should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
"describe something": { | ||
"should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
} | ||
}]; | ||
@@ -29,11 +33,15 @@ files = filesContent(); | ||
it("should tell when a nested match is not found", function() { | ||
it("should tell when a non suite-ed match is found", function() { | ||
var expected = responseObject(); | ||
expected.pending = [{ | ||
"describe something else should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
var expected = responseObject(), | ||
files; | ||
expected.passed = [{ | ||
"should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
}]; | ||
files = filesContent(); | ||
files[0]["describe something"] = {}; | ||
files[0]["describe something"]["else"] = {"should do something" : "test/fixtures/spec/exampleSpec.feature:1"}; | ||
files = [ | ||
{"should do something" : "test/fixtures/spec/exampleSpec.feature:1"}, | ||
{"should do something" : "PASSED"} | ||
]; | ||
objectsEqual(inspector(files), expected); | ||
@@ -46,4 +54,10 @@ }); | ||
[ | ||
{"first description should do something" : 'test/fixtures/spec/full.feature:2'}, | ||
{ "second description nested description should do something else" : "test/fixtures/spec/full.feature:6"} | ||
{"first description": { | ||
"should do something" : 'test/fixtures/spec/full.feature:2' | ||
} | ||
}, | ||
{"second description nested description" : { | ||
"should do something else" : "test/fixtures/spec/full.feature:6" | ||
} | ||
} | ||
]; | ||
@@ -57,6 +71,4 @@ | ||
}, | ||
"second description": { | ||
"nested description": { | ||
"should do something else": "test/fixtures/spec/full.feature:6" | ||
} | ||
"second description nested description": { | ||
"should do something else": "test/fixtures/spec/full.feature:6" | ||
} | ||
@@ -75,5 +87,5 @@ }; | ||
[ | ||
{ "first description should do something" : "test/fixtures/spec/full.feature:2"}, | ||
{ "second description nested description should do something else" : "test/fixtures/spec/full.feature:6"}, | ||
{ "second description nested description should do a final thing" : "test/fixtures/spec/full.feature:7"} | ||
{ "first description": {"should do something" : "test/fixtures/spec/full.feature:2"}}, | ||
{ "second description nested description": {"should do something else" : "test/fixtures/spec/full.feature:6"}}, | ||
{ "second description nested description": {"should do a final thing" : "test/fixtures/spec/full.feature:7"}} | ||
]; | ||
@@ -87,7 +99,5 @@ | ||
}, | ||
"second description": { | ||
"nested description": { | ||
"should do something else": "test/fixtures/spec/full.feature:6", | ||
"should do a final thing": "test/fixtures/spec/full.feature:7" | ||
} | ||
"second description nested description": { | ||
"should do something else": "test/fixtures/spec/full.feature:6", | ||
"should do a final thing": "test/fixtures/spec/full.feature:7" | ||
} | ||
@@ -105,3 +115,3 @@ }; | ||
expected.failed =[{ | ||
"describe something should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
"describe something": {"should do something": "test/fixtures/spec/exampleSpec.feature:1"} | ||
}]; | ||
@@ -116,3 +126,3 @@ files = filesContent(); | ||
expected.passed = [{ | ||
"describe something else should do something": "test/fixtures/spec/exampleSpec.feature:1" | ||
"describe something else": {"should do something": "test/fixtures/spec/exampleSpec.feature:1"} | ||
}]; | ||
@@ -154,13 +164,9 @@ objectsEqual(inspector(nestedFilesContent()), expected); | ||
return [{ | ||
"describe something" : { | ||
"else": { | ||
"should do something" : "test/fixtures/spec/exampleSpec.feature:1" | ||
} | ||
"describe something else" : { | ||
"should do something" : "test/fixtures/spec/exampleSpec.feature:1" | ||
} | ||
}, | ||
{ | ||
"describe something" : { | ||
"else": { | ||
"should do something" : "PASSED" | ||
} | ||
"describe something else" : { | ||
"should do something" : "PASSED" | ||
} | ||
@@ -167,0 +173,0 @@ }]; |
@@ -92,2 +92,22 @@ var markdownParser = require('../lib/markdownParser'), | ||
it("skips a file with a skip regardless of case", function(done){ | ||
var inputFile = "test/fixtures/markdown/upperSkip.md"; | ||
markdownParser(inputFile, function(spec) { | ||
assert.equal(spec.last, true); | ||
assert.equal(spec.skip, true); | ||
assert.equal(spec.description, null); | ||
done(); | ||
}); | ||
}); | ||
it("matches skips with no space between the chevron and skip keyword", function(done) { | ||
var inputFile = "test/fixtures/markdown/skipNoSpace.md"; | ||
markdownParser(inputFile, function(spec) { | ||
assert.equal(spec.last, true); | ||
assert.equal(spec.skip, true); | ||
assert.equal(spec.description, null); | ||
done(); | ||
}); | ||
}); | ||
it("skips everything after a skip", function(done) { | ||
@@ -105,2 +125,11 @@ var inputFile = "test/fixtures/markdown/skipPart.md"; | ||
it("strips its from the matched spec", function(done) { | ||
var inputFile = "test/fixtures/markdown/upperIT.md"; | ||
markdownParser(inputFile, function(spec) { | ||
assert.equal(spec.description, "should do something"); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,4 @@ var assert = require('assert'), | ||
describe("Spec collector", function() { | ||
@@ -23,2 +25,4 @@ var calls = [], | ||
mockery.enable(); | ||
mockery.warnOnReplace(false); | ||
mockery.warnOnUnregistered(false); | ||
transformerSpy = sinon.spy(transformer); | ||
@@ -25,0 +29,0 @@ |
@@ -9,3 +9,3 @@ (function(require){ | ||
var input = { | ||
passed: [{"This has passed" : "line"}], | ||
passed: [{"This has passed" : "line"}, {"This Suite": {"has also passed": "line"}}], | ||
failed: [{"This has failed" : "line"}], | ||
@@ -19,10 +19,13 @@ pending: [{"This is pending" : "line"}] | ||
assert.equal(result[2], "\u001b[31mThis has failed\u001b[39m"); | ||
assert.equal(result[2], "\u001b[32mThis Suite has also passed\u001b[39m"); | ||
assert.equal(result[3], "\u001b[90mline\u001b[39m"); | ||
assert.equal(result[4], "\u001b[33mThis is pending\u001b[39m"); | ||
assert.equal(result[4], "\u001b[31mThis has failed\u001b[39m"); | ||
assert.equal(result[5], "\u001b[90mline\u001b[39m"); | ||
assert.equal(result[6], "\u001b[33mThis is pending\u001b[39m"); | ||
assert.equal(result[7], "\u001b[90mline\u001b[39m"); | ||
}); | ||
}); | ||
})(require); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54384
52
1310
5
14
6
+ Addedxmlbuilder@~2.1.0
+ Addedunderscore@1.13.7(transitive)
+ Addedxmlbuilder@2.1.0(transitive)