Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (44 sloc) 1.56 KB



should      = require 'should'
nailCore    = require 'nail-core'
methods     = require('../coverage/instrument/lib/module.js').methods
_           = require 'underscore'
they        = it #more natural language for describing array properties


describe 'methods', ->
  it 'is an Object', ->
    (_.isObject methods)

The "aspect" properties defines which section of the class definition the module handles.

  it 'has a "aspect" string"', -> 'string'
  it 'its aspect is "methods"', ->
    methods.aspect.should.equal 'methods'

This aspect is optional.

  it 'does not crash if the class has no methods', ->
    Person = ->
    Person.definition = {}
    methods.augment Person

The augment function exists...

  it 'has a "augment" function', ->
    (_.isFunction methods.augment)

...and adds methods to the prototype.

  it 'adds a method to a class prototype', ->
    Person = ->
    Person.definition =
        hello: -> 'hello world'
    methods.augment Person
    x = new Person
    x.hello().should.equal 'hello world'

The module can be used as a nail module.

  it 'can be used as a nail module', ->
    nail = nailCore.use methods
    lib = Person:
        hello: -> 'hello world'
    x = new lib.Person
    x.hello().should.equal 'hello world'