Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

replaced Cakefile with Makefile. replaced jasmine-node with mocha and…

… should
  • Loading branch information...
commit 5c95f137a8de190407332a045b4d326a101a7e83 1 parent 2ede3f0
Nick Fisher authored
Showing with 31 additions and 78 deletions.
  1. +0 −71 Cakefile
  2. +21 −0 Makefile
  3. +4 −2 package.json
  4. +6 −5 spec/unit/merge.spec.coffee
View
71 Cakefile
@@ -1,71 +0,0 @@
-fs = require 'fs'
-path = require 'path'
-{spawn, exec} = require 'child_process'
-util = require 'util'
-
-# Use executables installed with npm bundle.
-process.env["PATH"] = "node_modules/.bin:#{process.env["PATH"]}"
-
-srcDir = "src"
-prodDir = "lib"
-testDir = "spec"
-
-# ANSI Terminal Colors.
-bold = "\033[0;1m"
-red = "\033[0;31m"
-green = "\033[0;32m"
-reset = "\033[0m"
-
-# Log a message with a color.
-log = (message, color, explanation) ->
- console.log color + message + reset + ' ' + (explanation or '')
-
-# Handle error and kill the process.
-onError = (err) ->
- if err
- process.stdout.write "#{red}#{err.stack}#{reset}\n"
- process.exit -1
-
-task 'clean', 'Remove temporary files', ->
- log 'Executing clean', green
- exec 'rm -rf lib reports logs/*.log', onError
-
-task 'build', 'Compile CoffeeScript into Javascript', ->
- exec "coffee -o #{prodDir} -c #{srcDir}", (err, stdout, stderror) ->
- onError err
-
-runTests = (dir) ->
- log "Running test suite for #{dir}...", green
- exec "jasmine-node --coffee --junitreport --verbose #{dir}", (err, stdout, stderr) ->
- console.log stdout if stdout
- console.error stderr if stderr
- process.stdout.on 'drain', ->
- process.exit -1 if err
-
-runOnChange = (task_to_invoke) ->
- exec "find #{srcDir} #{testDir}", (err, stdout, stderr) ->
- files = stdout.split '\n'
- files = files[0..files.length - 2]
- files.forEach (file) ->
- fs.stat file, (err, stats) ->
- if stats.isFile()
- fs.watch file, (event, filename) ->
- invoke task_to_invoke
-
-task 'test', 'Run all tests', ->
- runTests "#{testDir}/"
-
-task 'test:unit', 'Run unit tests', ->
- runTests "#{testDir}/unit/"
-
-task 'test:integration', 'Run unit tests', ->
- runTests "#{testDir}/integration/"
-
-task '~test:unit', 'Rebuild and rerun tests on changes to src', ->
- runOnChange 'test:unit'
-
-task '~test:integration', 'Rebuild and rerun tests on changes to src', ->
- runOnChange 'test:integration'
-
-task '~test', 'Rebuild and rerun tests on changes to src', ->
- runOnChange 'test'
View
21 Makefile
@@ -0,0 +1,21 @@
+UNIT_TESTS = $(shell find spec/unit -name "*.spec.coffee")
+INTEGRATION_TESTS = $(shell find spec/integration -name "*.spec.coffee")
+ALL_TESTS = $(shell find spec -name "*.spec.coffee")
+
+build:
+ coffee -o lib -c src
+
+clean:
+ rm -rf lib reports logs/*.log
+
+test:
+ @./node_modules/mocha/bin/mocha --compilers coffee:coffee-script $(ALL_TESTS)
+
+test_unit:
+ @./node_modules/mocha/bin/mocha --compilers coffee:coffee-script $(UNIT_TESTS)
+
+test_integration:
+ @./node_modules/mocha/bin/mocha --compilers coffee:coffee-script $(INTEGRATION_TESTS)
+
+.PHONY:
+ clean build test
View
6 package.json
@@ -2,7 +2,7 @@
"author": "Nick Fisher",
"name": "deepmerge",
"description": "A library for deep (recursive) merging of Javascript objects",
- "version": "0.0.1",
+ "version": "0.1.0",
"homepage": "https://github.com/nrf110/deepmerge",
"repository": {
"type": "git",
@@ -14,6 +14,8 @@
},
"dependencies": {},
"devDependencies": {
- "jasmine-node": "~1.0.20"
+ "mocha": "1.0.0",
+ "coffee-script": "1.2.0",
+ "should": "0.6.0"
}
}
View
11 spec/unit/merge.spec.coffee
@@ -1,3 +1,4 @@
+should = require 'should'
merge = require '../../lib/merge'
describe 'merge', ->
@@ -11,7 +12,7 @@ describe 'merge', ->
merge target, src
- expect(target).toEqual(target)
+ target.should.eql target
it 'should merge existing simple keys in target at the roots', ->
src =
@@ -28,7 +29,7 @@ describe 'merge', ->
merge target, src
- expect(target).toEqual(expected)
+ target.should.eql expected
it 'should merge nested objects into target', ->
src =
@@ -48,7 +49,7 @@ describe 'merge', ->
merge target, src
- expect(target).toEqual(expected)
+ target.should.eql expected
it 'should replace simple key with nested object in target', ->
src =
@@ -67,7 +68,7 @@ describe 'merge', ->
merge target, src
- expect(target).toEqual(expected)
+ target.should.eql expected
it 'should replace object with simple key in target', ->
src =
@@ -84,5 +85,5 @@ describe 'merge', ->
merge target, src
- expect(target).toEqual(expected)
+ target.should.eql expected
Please sign in to comment.
Something went wrong with that request. Please try again.