Skip to content

Instantly share code, notes, and snippets.

@twada
Last active January 31, 2016 10:50
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twada/dd04b07f3a197456ed20 to your computer and use it in GitHub Desktop.
Save twada/dd04b07f3a197456ed20 to your computer and use it in GitHub Desktop.
espower-coffee を使ってコード生成を経ずに (gulp-espower を使わずに) CoffeeScript + power-assert を使うデモ (npm test でも gulp test でも動きます)
var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('test', function () {
require('espower-coffee/guess');
return gulp
.src('test/**/*.coffee')
.pipe(mocha());
});
{
"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 <takuto.wada@gmail.com>",
"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"
}
}
# このファイルは 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
@twada
Copy link
Author

twada commented Dec 8, 2014

various_types_test.coffee は test ディレクトリを作成してそこに入れてください。そうすればあとは npm install するだけで無設定で変換できます。 test ディレクトリ以外に置く場合には明示的に設定を書く必要があります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment