Sha256: 2fcebc4869b9b0cf60f46c4f2589c4de65f72640f6d2956ea261cbf98746bd86
Contents?: true
Size: 1.33 KB
Versions: 16
Compression:
Stored size: 1.33 KB
Contents
/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca> * MIT Licensed */ module.exports = function(should, Assertion) { Assertion.add('NaN', function() { this.params = { operator: 'to be NaN' }; this.is.a.Number .and.assert(isNaN(this.obj)); }, true); Assertion.add('Infinity', function() { this.params = { operator: 'to be Infinity' }; this.is.a.Number .and.not.a.NaN .and.assert(!isFinite(this.obj)); }, true); Assertion.add('within', function(start, finish, description) { this.params = { operator: 'to be within ' + start + '..' + finish, message: description }; this.assert(this.obj >= start && this.obj <= finish); }); Assertion.add('approximately', function(value, delta, description) { this.params = { operator: 'to be approximately ' + value + " ±" + delta, message: description }; this.assert(Math.abs(this.obj - value) <= delta); }); Assertion.add('above', function(n, description) { this.params = { operator: 'to be above ' + n, message: description }; this.assert(this.obj > n); }); Assertion.add('below', function(n, description) { this.params = { operator: 'to be below ' + n, message: description }; this.assert(this.obj < n); }); Assertion.alias('above', 'greaterThan'); Assertion.alias('below', 'lessThan'); };
Version data entries
16 entries across 16 versions & 1 rubygems