Permalink
Browse files

major overhaul and elimination of node.js testing

  • Loading branch information...
1 parent 1aa950f commit d093b69a7206bbdbf50c6dfbdc10d0a27919dfad @quartzmo committed Mar 4, 2012
Showing with 5,896 additions and 68 deletions.
  1. +0 −1 .gitignore
  2. +8 −19 Makefile
  3. +4 −8 Readme.md
  4. +1 −1 {lib → }/example.js
  5. +0 −1 index.js
  6. +0 −19 package.json
  7. +1 −1 src/example.coffee
  8. +12 −7 test/{browser → }/index.html
  9. +1 −6 test/lib/example.js
  10. +0 −2 test/mocha.opts
  11. +1 −3 test/src/example.coffee
  12. +2,142 −0 test/vendor/chai.js
  13. +137 −0 test/vendor/mocha.css
  14. +3,589 −0 test/vendor/mocha.js
View
@@ -1,2 +1 @@
.DS_Store
-node_modules
View
@@ -1,31 +1,20 @@
-REPORTER = dot
-
-all: build
+all: build test-build
build:
- @./node_modules/coffee-script/bin/coffee \
- -c \
- -o lib src
+ coffee -c -o . src
test-build:
- @./node_modules/coffee-script/bin/coffee \
- -c \
- -o test/lib test/src
+ coffee -c -o test/lib test/src
clean:
- rm -rf lib
+ rm ./*.js
rm -rf test/lib
- mkdir lib
mkdir test/lib
watch:
- @./node_modules/coffee-script/bin/coffee \
- -o lib \
- -cw src
+ coffee -o . -cw src
-test: build test-build
- @./node_modules/mocha/bin/mocha \
- --reporter $(REPORTER) \
- test/lib/*.js
+test-watch:
+ coffee -o test/lib -cw test/src
-.PHONY: build clean watch test test-build
+.PHONY: build test-build clean watch test-watch
View
@@ -1,19 +1,15 @@
# Mocha Browser & CoffeeScript Boilerplate
A minimalistic boilerplate for a browser-based CoffeeScript project that is tested with [visionmedia/mocha](http://visionmedia.github.com/mocha).
-Uses [Expect](https://github.com/LearnBoost/expect.js) instead of Should for browser compatibility.
-Requires Node.js for command-line test run. Node is **not** required for the browser-based test run.
-
-For a more extensive demo of Mocha's featureset, take a look at [ryu22e/mocha-example](https://github.com/ryu22e/mocha-example).
+Uses Chai instead of Should for browser compatibility.
+Requires CoffeeScript's `coffee` executable in path for make compilation. CoffeeScript, NPM, and Node are **not** required for the browser-based test run.
## Usage
1. `rm -rf .git`
-1. `npm install .`
-1. `make test`
1. Replace `example.coffee` in both `test` and `src` with your own code.
-1. Edit `Readme.md`, `package.json`, and `index.js`, replacing this project's details with your own.
-1. `make clean build test`
+1. `make` to compile source and test CoffeeScript, or else `make watch` and `make test-watch` for automatic compilation
+1. Edit `Readme.md`, replacing this project's details with your own.
## License
@@ -1,7 +1,7 @@
(function() {
var Example;
- Example = typeof window !== "undefined" && window !== null ? window.Example = {} : exports;
+ Example = window.Example = {};
Example.truth = function() {
return true;
View
@@ -1 +0,0 @@
-module.exports = require('./lib/example');
View
@@ -1,19 +0,0 @@
-{
- "name": "mocha-browser-boilerplate"
- , "version": "0.0.1"
- , "description": "minimalistic template for a browser-based CoffeeScript project tested with visionmedia/mocha"
- , "keywords": ["mocha", "boilerplate", "test", "coffeescript", "coffee-script"]
- , "author": "Chris Smith <quartzmo@gmail.com>"
- , "main": "index"
- , "engines": { "node": ">= 0.4.x < 0.8.0" }
- , "scripts": {
- "test": "make test"
- }
- , "dependencies":{
- "coffee-script": ">= 1.2.0"
- }
- , "devDependencies": {
- "mocha": ">= 0.11.0"
- , "expect.js": ">= 0.1.2"
- }
-}
View
@@ -1,3 +1,3 @@
-Example = if window? then window.Example = {} else exports
+Example = window.Example = {}
Example.truth = -> true
@@ -4,21 +4,26 @@
<head>
<meta charset="utf-8">
<title>Exercises.js Tests</title>
- <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
+ <link rel="stylesheet" href="vendor/mocha.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
- <script src="../../node_modules/mocha/mocha.js"></script>
- <script src="../../node_modules/expect.js/expect.js"></script>
- <script>mocha.setup('bdd')</script>
- <script src="../../lib/example.js"></script>
- <script src="../lib/example.js"></script>
+ <script src="vendor/mocha.js"></script>
+ <script src="vendor/chai.js"></script>
<script>
+ chai.should();
+ mocha.setup('bdd');
$(function () {
mocha
.run()
.globals(['Example']) // acceptable globals
})
</script>
+
+ <!-- include source files here... -->
+ <script src="../example.js"></script>
+
+
+ <script src="lib/example.js"></script>
+
</head>
<body>
<div id="mocha"></div>
View
@@ -1,14 +1,9 @@
(function() {
- var Example, expect, _ref, _ref2;
-
- expect = (_ref = typeof window !== "undefined" && window !== null ? window.expect : void 0) != null ? _ref : typeof require === "function" ? require('expect.js') : void 0;
-
- Example = (_ref2 = typeof window !== "undefined" && window !== null ? window.Example : void 0) != null ? _ref2 : typeof require === "function" ? require('../../') : void 0;
describe('Example', function() {
return describe('#truth()', function() {
return it('should return Boolean true', function() {
- return expect(Example.truth()).to.be(true);
+ return Example.truth().should.be["true"];
});
});
});
View
@@ -1,2 +0,0 @@
---reporter dot
---ui bdd
View
@@ -1,6 +1,4 @@
-expect = window?.expect ? require?('expect.js')
-Example = window?.Example ? require?('../../')
describe 'Example', ->
describe '#truth()', ->
it 'should return Boolean true', ->
- expect(Example.truth()).to.be true
+ Example.truth().should.be.true
Oops, something went wrong.

0 comments on commit d093b69

Please sign in to comment.