From b9596a7ccf4e092a90b46bf096ed5cefaaeed5ed Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Tue, 28 Apr 2015 15:41:57 +0200 Subject: [PATCH] implementato sistema di controllo copertura test --- .gitignore | 1 + asjon-testing.coffee | 3 +-- package.json | 17 ++++++++++++----- scripts/shell.coffee | 6 +++--- test/shell-test.coffee | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 7959f92..55c0e0f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ hubot.lua run.sh run_telegram.sh *.pub +coverage/ .telegram/ telegram.config diff --git a/asjon-testing.coffee b/asjon-testing.coffee index 20ac130..a7cd725 100644 --- a/asjon-testing.coffee +++ b/asjon-testing.coffee @@ -1,5 +1,4 @@ -#expect = require("chai").expect -path = require("path") +path = require "path" Robot = require("hubot/src/robot") TextMessage = require("hubot/src/message").TextMessage diff --git a/package.json b/package.json index 2d4fa88..edd5d2d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,10 @@ "author": "Enrico Fasoli ", "description": "Il miglior amico della 5IA", "dependencies": { + "chai": "^2.3.0", "cheerio": "^0.19.0", + "coffee-coverage": "^0.4.6", + "coffee-script": "^1.9.2", "github": "^0.2.4", "htmlparser": "^1.7.7", "hubot": "^2.12.0", @@ -16,6 +19,7 @@ "hubot-help": "^0.1.1", "hubot-heroku-keepalive": "0.0.4", "hubot-maps": "0.0.2", + "hubot-mock-adapter": "^1.0.0", "hubot-pugme": "^0.1.0", "hubot-redis-brain": "0.0.2", "hubot-rules": "^0.1.0", @@ -25,20 +29,23 @@ "hubot-youtube": "^0.1.2", "moment": "^2.10.2", "nightmare": "^1.8.0", + "nock": "^1.7.1", "nodepie": "^0.6.7", "soupselect": "^0.2.0", "weak": "^0.4.0", "wolfram": "^0.3.1" }, + "config": { + "blanket": { + "pattern": "" + } + }, "scripts": { + "coverage-html": "mkdir -p coverage && mocha test/ --require coffee-coverage/register --compilers coffee:coffee-script/register -R html-cov scripts/ > coverage/coverage.html", + "coverage-json": "mkdir -p coverage && mocha test/ --require coffee-coverage/register --compilers coffee:coffee-script/register -R json-cov scripts/ > coverage/coverage.json", "test": "mocha test/ --compilers coffee:coffee-script/register" }, "engines": { "node": "0.10.x" - }, - "devDependencies": { - "chai": "^2.3.0", - "hubot-mock-adapter": "^1.0.0", - "nock": "^1.7.1" } } diff --git a/scripts/shell.coffee b/scripts/shell.coffee index 7bbdfdc..29a0437 100644 --- a/scripts/shell.coffee +++ b/scripts/shell.coffee @@ -33,7 +33,7 @@ runCmd = (cmd,res,cb) -> module.exports = (robot) -> robot.respond /aggiornati|scarica (?:gli )?aggiornamenti/i, (res) -> if !isFromAdmin(res) then return res.send res.random nope - runCmd 'git pull && npm install && npm install --dev', res + runCmd 'git pull && npm install', res robot.respond /(?:controlla gli )?aggiornamenti/i, (res) -> if !isFromAdmin(res) then return res.send res.random nope @@ -41,7 +41,7 @@ module.exports = (robot) -> robot.respond /(?:installa (?:le )?)?dipendenze/i, (res) -> if !isFromAdmin(res) then return res.send res.random nope - runCmd 'npm install && npm install --dev', res + runCmd 'npm install', res robot.respond /(?:esegui (?:i )?)?test/i, (res) -> if !isFromAdmin(res) then return res.send res.random nope @@ -59,7 +59,7 @@ module.exports = (robot) -> robot.on 'githubhook', (data,params) -> if data.ref is 'refs/heads/master' and process.env.AUTO_KILL_ON_UPDATE - runCmd 'git pull && npm install && npm install --dev', null, -> + runCmd 'git pull && npm install', null, -> dest = name: params.name, room: params.room.replace(':','#') robot.send dest, 'riavvio in 5 SECONDI' reboot = -> diff --git a/test/shell-test.coffee b/test/shell-test.coffee index 52219ca..ee06b5c 100644 --- a/test/shell-test.coffee +++ b/test/shell-test.coffee @@ -33,7 +33,7 @@ describe 'modulo shell', -> asjon.send 'asjon controlla gli aggiornamenti' it 'dovrebbe eseguire i comandi corretti per installare gli aggiornamenti', (done) -> - cmd = 'git pull && npm install && npm install --dev' + cmd = 'git pull && npm install' acc = 0 asjon.receive (e,l) -> l.join().should.equal ss[acc]+cmd @@ -51,7 +51,7 @@ describe 'modulo shell', -> asjon.send 'asjon controlla gli aggiornamenti' it 'dovrebbe eseguire i comandi corretti per installare le dipendenze', (done) -> - cmd = 'npm install && npm install --dev' + cmd = 'npm install' acc = 0 asjon.receive (e,l) -> l.join().should.equal ss[acc]+cmd