Last active
January 31, 2016 10:50
-
-
Save twada/dd04b07f3a197456ed20 to your computer and use it in GitHub Desktop.
espower-coffee を使ってコード生成を経ずに (gulp-espower を使わずに) CoffeeScript + power-assert を使うデモ (npm test でも gulp test でも動きます)
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 gulp = require('gulp'); | |
var mocha = require('gulp-mocha'); | |
gulp.task('test', function () { | |
require('espower-coffee/guess'); | |
return gulp | |
.src('test/**/*.coffee') | |
.pipe(mocha()); | |
}); |
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
{ | |
"name": "espower-coffee-demo", | |
"private": true, | |
"version": "1.0.0", | |
"description": "espower-coffee Demo", | |
"scripts": { | |
"test": "mocha --require espower-coffee/guess test/**/*.coffee" | |
}, | |
"author": "Takuto Wada <[email protected]>", | |
"license": "MIT", | |
"devDependencies": { | |
"coffee-script": "^1.8.0", | |
"espower-coffee": "^0.10.0", | |
"gulp": "^3.8.10", | |
"gulp-mocha": "^2.0.0", | |
"mocha": "^2.0.1", | |
"power-assert": "^0.10.0" | |
} | |
} |
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
# このファイルは test ディレクトリに置いてください | |
assert = require 'power-assert' | |
class Person | |
constructor: (name, age) -> | |
@name = name | |
@age = age | |
describe "Coffee various types", -> | |
beforeEach -> | |
@types = [ | |
"string" | |
98.6 | |
true | |
false | |
null | |
`undefined` | |
[ | |
"nested" | |
"array" | |
] | |
{ | |
object: true | |
} | |
NaN | |
Infinity | |
/^not/ | |
new Person("alice", 3) | |
] | |
it "demo", -> | |
index = @types.length - 1 | |
bob = new Person("bob", 5) | |
assert @types[index].name is bob.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
various_types_test.coffee
は test ディレクトリを作成してそこに入れてください。そうすればあとはnpm install
するだけで無設定で変換できます。 test ディレクトリ以外に置く場合には明示的に設定を書く必要があります。