New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

spec-detective

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spec-detective - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

lib/parserFactory.js

6

lib/featureTransformer.js

@@ -1,6 +0,8 @@

var featureParser = require('./featureParser');
var ParserFactory = require('./parserFactory');
function transformFeature(input, callback) {
var output = {};
featureParser(input, function(spec){
var factory = new ParserFactory();
var parser = factory.getParserForString(input);
parser(input, function(spec){
handleSpec(spec, output, callback);

@@ -7,0 +9,0 @@ });

@@ -5,5 +5,6 @@ var lineReader = require('line-reader');

var output = {suite: [], last: false};
//TODO: Refactor these into modules to by DRY
var lineTypes = {
'SPEC' : {
tokens: ['*', '+'],
tokens: ['+'],
match: function(line) {

@@ -39,2 +40,14 @@ for(var i = 0; i < this.tokens.length; i++) {

}
},
'SKIP' : {
tokens: ['> skip'],
match: function(line) {
for(var i = 0; i < this.tokens.length; i++) {
var regex = new RegExp('\\' + this.tokens[i] + '([^\n]*)');
if(line.match(regex)) {
return line.match(regex);
}
}
return false;
}
}

@@ -56,16 +69,28 @@ }

function handleLine(line, callback) {
var type = getLineType(line);
var typeObject = lineTypes[type];
switch(type) {
case 'SPEC':
output.description = typeObject.strip(line);
if(!output.skip) {
var type = getLineType(line);
var typeObject = lineTypes[type];
switch(type) {
case 'SPEC':
output.description = typeObject.strip(line);
callback(output);
return;
case 'DESCRIBE':
//place the describe at the correct level
output.suite[typeObject.level(line) -1] = typeObject.strip(line);
//strip describes that are closed
output.suite = output.suite.splice(0, typeObject.level(line));
return;
case 'SKIP' :
output.skip = true;
output.last = true;
}
if(output.last) {
output.description = null;
output.last = true;
callback(output);
break;
case 'DESCRIBE':
//place the describe at the correct level
output.suite[typeObject.level(line) -1] = typeObject.strip(line);
//strip describes that are closed
output.suite = output.suite.splice(0, typeObject.level(line));
break;
}
}
}

@@ -79,5 +104,5 @@

}
}
}
return null;
}

@@ -84,0 +109,0 @@

{
"name": "spec-detective",
"version": "0.0.2",
"version": "0.0.3",
"description": "A cool way to find out if your spec's in feature files and the like have met expectations.",

@@ -9,2 +9,5 @@ "main": "index.js",

},
"bin": {
"detect": "./bin/spec-detective"
},
"repository": {

@@ -11,0 +14,0 @@ "type": "git",

@@ -7,3 +7,3 @@ var featureTransformer = require('../lib/featureTransformer'),

describe("Tranformation", function() {
describe("Transformation", function() {

@@ -14,3 +14,3 @@ it("transforms a single IT", function(done) {

"should do something" : "test/fixtures/spec/exampleSpec.feature:1"
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -26,3 +26,3 @@

}
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -41,3 +41,3 @@

}
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -52,3 +52,3 @@ });

}
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -68,3 +68,3 @@ });

}
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -84,3 +84,3 @@ });

}
}
};
verifyOutput(inputFile, expectedOutput, done);

@@ -98,3 +98,3 @@ });

'should NOT display the tab on fallback devices/browsers.' : "test/fixtures/spec/realSpec.feature:13"
}
};

@@ -104,2 +104,15 @@ verifyOutput(inputFile, expectedOutput, done);

describe("parsing markdown", function() {
it("can parse a markdown file", function(done) {
var inputFile = "test/fixtures/markdown/describe.md";
var expectedOutput = {
"a description" : {
"should do something" : "test/fixtures/markdown/describe.md:2"
}
};
verifyOutput(inputFile, expectedOutput, done);
});
});
function verifyOutput(inputFile, expectedOutput, done) {

@@ -106,0 +119,0 @@

# a description
* it should do something
+ it should do something
# a describe
## another describe
* a spec
+ a spec
# reset describe
* a second spec
+ a second spec

@@ -1,1 +0,1 @@

* it should do something
+ it should do something
# a description
## another description
* a spec
+ a spec
## a third description
### a fourth description
* a second spec
+ a second spec
# a description
- a spec
* ignore
+ a second spec

@@ -8,3 +8,3 @@ (function(require){

describe.only("Inspector full", function() {
describe("Inspector full", function() {
it("should match top level specs", function() {

@@ -11,0 +11,0 @@ var expected = [

@@ -67,3 +67,39 @@ var markdownParser = require('../lib/markdownParser'),

});
//+ a spec
/// -----> empty last line
it("handles files with extra returns", function(done) {
var inputFile = "test/fixtures/markdown/emptyLast.md";
var count = 0;
markdownParser(inputFile, function(spec) {
count++;
if(count == 2) {
assert.equal(spec.last, true);
assert.equal(spec.description, null);
done();
}
});
});
it("skips a file with a chevron on the first line", function(done) {
var inputFile = "test/fixtures/markdown/skipFile.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) {
var inputFile = "test/fixtures/markdown/skipPart.md";
var count = 0;
markdownParser(inputFile, function(spec) {
count++;
if(count >= 2) {
assert.equal(spec.skip, true);
done();
}
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc