bootcamp
Version:
A pure Sass testing framework in the style of Jasmine
84 lines (67 loc) • 2.33 kB
text/coffeescript
'use strict'
bootcamp = require '../dist/bootcamp.coffee'
colors = require 'colors'
module.exports = (grunt) ->
grunt.registerMultiTask 'bootcamp', 'Jasmine-style BDD testing written in Sass for Sass.', ->
class bootcamp.gruntTask
constructor: () ->
if .incomplete
else if .success and .test == 0
else if .success
else
log: (string) -> grunt.log.writeln string
pass: (string) -> grunt.log.success string
warn: (string) -> grunt.log.warn string
fail: (string) -> grunt.fail.warn string
logStats: ->
stats = .stats + ''
stats = stats.replace /✔/g, '✔'.green
stats = stats.replace /✗/g, '✗'.red
stats
logSpecs: ->
specs = .specs + ''
specs = specs.replace /✔/g, '✔'.green
specs = specs.replace /✗/g, '✗'.red
specs = specs.replace /Test Passed/g, 'Test passed'.green
specs = specs.replace /Test Failed/g, 'Test failed'.red
specs = specs.replace /!(.*)!(.*)\./g, '$1:$2.'.yellow
specs = specs.trim()
if specs != ''
'\n' + specs + '\n'
logErrors: ->
if !.errors then return null
''
for error in .errors
error = error + ''
error = error.replace /!(.*)!(.*)/g, '$1:'.red + '$2'.yellow
error.yellow
isIncomplete: ->
.error.yellow
return true
isEmpty: ->
'Your tests probably haven\'t been properly set up.\nTake a look at https://github.com/thejameskyle/bootcamp/wiki/setup'
return true
hasFailed: ->
.details
return false
hasPassed: ->
.details
return true
.forEach (f) ->
f.src.filter (filepath) ->
unless grunt.file.exists filepath
grunt.log.warn 'Source file "' + filepath + '" not found.'
return false
else
new bootcamp.gruntTask bootcamp.test filepath