How do you create a CoffeeScript class instance using 'apply'?
The answer is, like this:
util = require('util')
assert = require('assert')
class MyClass
constructor: (@splatArgs...) -> @first = splatArgs[0]; @second = splatArgs[1]
describe 'apply on a CoffeeScript class', ->
describe 'with splatArgs[1,2]', ->
theInstance = {}
MyClass.apply(theInstance, [1, 2])
it 'should have a splatArgs.length of 2', -> assert.equal theInstance.splatArgs.length, 2
it 'should have a first of value 1', -> assert.equal theInstance.first, 1
it 'should have a second of value 2', -> assert.equal theInstance.second, 2
it 'should have splatArgs of [1,2]', -> assert.deepEqual theInstance.splatArgs, [1,2]