-
-
Save stahnma/29c40ccd36241aebe68852895d670167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expect, fs; | |
expect = require('chai').expect; | |
fs = require('fs'); | |
// list all files in scripts | |
// check each script for a Category comment | |
// fail if it's missing | |
describe('category', function() { | |
var bool, f, re, results, text; | |
re = /[\#|\/\/]\s+category[:?]\s+(workflow|social)/i; | |
results = []; | |
fs.readdirSync('tt').forEach(function(f) { | |
describe("All scripts should have a category", function() { | |
it("Should have a known category for " + f, function(done) { | |
text = fs.readFileSync('./tt/' + f).toString(); | |
bool = re.test(text); | |
results.push(expect(bool).to.eql(true)); | |
done(); | |
}) | |
return results; | |
}); | |
}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env coffee | |
Helper = require('hubot-test-helper') | |
expect = require('chai').expect | |
fs = require 'fs' | |
# Objective | |
# list all files in scripts | |
# check each script for a Category comment | |
# fail if it's missing | |
describe 'category', -> | |
context "All scripts should have a category", -> | |
files = fs.readdirSync('tt'); | |
re = /category/i | |
for f in files | |
it "ensures a category exists for #{f}", -> | |
text = fs.readFileSync('./tt/' + f).toString(); # f is always the same value here, because non-blocking IO is dumb (or I am) | |
console.log(text) | |
bool = re.test(text) | |
expect(bool).to.eql(true) |
stephenyeargin
commented
Oct 23, 2018
Drawback: It will fail on first file that doesn't have a category
Positive: It works.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment