spec/lib/jspec.js
function(description, body) {
      extend(this, {
        body: body,
        description: description,
        assertions: [],
        
        // Add passing assertion
        
        pass : function(message) {
          this.assertions.push({ passed: true, message: message })
          if (JSpec.assert) ++JSpec.stats.passes
        },
        
        // Add failing assertion
        
        fail : function(message) {
          this.assertions.push({ passed: false, message: message })
          if (JSpec.assert) ++JSpec.stats.failures
        },
                
        // Run deferred assertions
        
        runDeferredAssertions : function() {
          each(this.assertions, function(assertion){
            if (assertion.defer) assertion.run().report(), hook('afterAssertion', assertion)
          })
        },
        
        // Find first failing assertion

        failure : function() {
          return find(this.assertions, function(assertion){
            return !assertion.passed
          })
        },

        // Find all failing assertions

        failures : function() {
          return select(this.assertions, function(assertion){
            return !assertion.passed
          })
        },

        // Weither or not the spec passed

        passed : function() {
          return !this.failure()
        },

        // Weither or not the spec requires implementation (no assertions)

        requiresImplementation : function() {
          return this.assertions.length == 0
        },

        // Sprite based assertions graph

        assertionsGraph : function() {
          return map(this.assertions, function(assertion){
            return '<span class="assertion ' + (assertion.passed ? 'passed' : 'failed') + '"></span>'
          }).join('')
        }
      })
    }
function(description, body) {
      extend(this, {
        body: body,
        description: description,
        assertions: [],
        
        // Add passing assertion
        
        pass : function(message) {
          this.assertions.push({ passed: true, message: message })
          if (JSpec.assert) ++JSpec.stats.passes
        },
        
        // Add failing assertion
        
        fail : function(message) {
          this.assertions.push({ passed: false, message: message })
          if (JSpec.assert) ++JSpec.stats.failures
        },
                
        // Run deferred assertions
        
        runDeferredAssertions : function() {
          each(this.assertions, function(assertion){
            if (assertion.defer) assertion.run().report(), hook('afterAssertion', assertion)
          })
        },
        
        // Find first failing assertion

        failure : function() {
          return find(this.assertions, function(assertion){
            return !assertion.passed
          })
        },

        // Find all failing assertions

        failures : function() {
          return select(this.assertions, function(assertion){
            return !assertion.passed
          })
        },

        // Weither or not the spec passed

        passed : function() {
          return !this.failure()
        },

        // Weither or not the spec requires implementation (no assertions)

        requiresImplementation : function() {
          return this.assertions.length == 0
        },

        // Sprite based assertions graph

        assertionsGraph : function() {
          return map(this.assertions, function(assertion){
            return '<span class="assertion ' + (assertion.passed ? 'passed' : 'failed') + '"></span>'
          }).join('')
        }
      })
    }
function ( description , body ) { extend ( this , { body : body , description : description , assertions : [ ] , // Add passing assertion pass : function ( message ) { this . assertions . push ( { passed : true , message : message } ) if ( JSpec . assert ) ++ JSpec . stats . passes } , // Add failing assertion fail : function ( message ) { this . assertions . push ( { passed : false , message : message } ) if ( JSpec . assert ) ++ JSpec . stats . failures } , // Run deferred assertions runDeferredAssertions : function ( ) { each ( this . assertions , function ( assertion ) { if ( assertion . defer ) assertion . run ( ) . report ( ) , hook ( 'afterAssertion' , assertion ) } ) } , // Find first failing assertion failure : function ( ) { return find ( this . assertions , function ( assertion ) { return ! assertion . passed } ) } , // Find all failing assertions failures : function ( ) { return select ( this . assertions , function ( assertion ) { return ! assertion . passed } ) } , // Weither or not the spec passed passed : function ( ) { return ! this . failure ( ) } , // Weither or not the spec requires implementation (no assertions) requiresImplementation : function ( ) { return this . assertions . length == 0 } , // Sprite based assertions graph assertionsGraph : function ( ) { return map ( this . assertions , function ( assertion ) { return '<span class="assertion ' + ( assertion . passed ? 'passed' : 'failed' ) + '"></span>' } ) . join ( '' ) } } ) }
Specification block object.

@param {string} description
@param {function} body
@api private
Specification block object .