Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (41 sloc) 1.327 kb
_ = require('underscore')
invoke = (method_name, args...) ->
if _.isFunction(@actual[method_name])
@actual[method_name].apply(@actual, args)
else
args.unshift(@actual)
_[method_name].apply(@actual, args)
beforeEach ->
@addMatchers
toBeEmpty: ->
invoke.call(this, 'isEmpty')
toInclude: (items...) ->
_(items).all (item) =>
invoke.call(this, 'include', item)
toIncludeAny: (items...) ->
_(items).any (item) =>
invoke.call(this, 'include', item)
toBeCompact: ->
elements = invoke.call(this, 'map', _.identity)
_.isEqual elements, _.compact(elements)
toBeUnique: ->
elements = invoke.call(this, 'map', _.identity)
_.isEqual elements, _.uniq(elements)
toRespondTo: (methods...)->
_.all methods, (method) =>
_.isFunction(@actual[method])
toRespondToAny: (methods...)->
_.any methods, (method) =>
_.isFunction(@actual[method])
toHave: (attrs...) ->
_.all attrs, (attr) =>
invoke.call(this, 'has', attr)
toHaveAny: (attrs...) ->
_.any attrs, (attr) =>
invoke.call(this, 'has', attr)
toBeAnInstanceOf: (clazz) ->
@actual instanceof clazz
toBeA: (clazz) ->
@actual instanceof clazz
toBeAn: (clazz) ->
@actual instanceof clazz
Jump to Line
Something went wrong with that request. Please try again.