spec/lib/jspec.js
function(description, body) {
      var self = this
      extend(this, {
        body: body,
        description: description,
        suites: [],
        specs: [],
        ran: false,
        hooks: { 'before' : [], 'after' : [], 'before_each' : [], 'after_each' : [] },
        
        // Add a spec to the suite

        addSpec : function(description, body) {
          var spec = new JSpec.Spec(description, body)
          this.specs.push(spec)
          JSpec.stats.specs++ // TODO: abstract
          spec.suite = this
        },

        // Add a hook to the suite

        addHook : function(hook, body) {
          this.hooks[hook].push(body)
        },

        // Add a nested suite

        addSuite : function(description, body) {
          var suite = new JSpec.Suite(description, body)
          JSpec.allSuites.push(suite)
          suite.name = suite.description
          suite.description = this.description + ' ' + suite.description
          this.suites.push(suite)
          suite.suite = this
        },

        // Invoke a hook in context to this suite

        hook : function(hook) {
          if (this.suite) this.suite.hook(hook)
          each(this.hooks[hook], function(body) {
            JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + self.description + "': ")
          })
        },

        // Check if nested suites are present

        hasSuites : function() {
          return this.suites.length  
        },

        // Check if this suite has specs

        hasSpecs : function() {
          return this.specs.length
        },

        // Check if the entire suite passed

        passed : function() {
          return !any(this.specs, function(spec){
            return !spec.passed() 
          })
        }
      })
    }
function(description, body) {
      var self = this
      extend(this, {
        body: body,
        description: description,
        suites: [],
        specs: [],
        ran: false,
        hooks: { 'before' : [], 'after' : [], 'before_each' : [], 'after_each' : [] },
        
        // Add a spec to the suite

        addSpec : function(description, body) {
          var spec = new JSpec.Spec(description, body)
          this.specs.push(spec)
          JSpec.stats.specs++ // TODO: abstract
          spec.suite = this
        },

        // Add a hook to the suite

        addHook : function(hook, body) {
          this.hooks[hook].push(body)
        },

        // Add a nested suite

        addSuite : function(description, body) {
          var suite = new JSpec.Suite(description, body)
          JSpec.allSuites.push(suite)
          suite.name = suite.description
          suite.description = this.description + ' ' + suite.description
          this.suites.push(suite)
          suite.suite = this
        },

        // Invoke a hook in context to this suite

        hook : function(hook) {
          if (this.suite) this.suite.hook(hook)
          each(this.hooks[hook], function(body) {
            JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + self.description + "': ")
          })
        },

        // Check if nested suites are present

        hasSuites : function() {
          return this.suites.length  
        },

        // Check if this suite has specs

        hasSpecs : function() {
          return this.specs.length
        },

        // Check if the entire suite passed

        passed : function() {
          return !any(this.specs, function(spec){
            return !spec.passed() 
          })
        }
      })
    }
function ( description , body ) { var self = this extend ( this , { body : body , description : description , suites : [ ] , specs : [ ] , ran : false , hooks : { 'before' : [ ] , 'after' : [ ] , 'before_each' : [ ] , 'after_each' : [ ] } , // Add a spec to the suite addSpec : function ( description , body ) { var spec = new JSpec . Spec ( description , body ) this . specs . push ( spec ) JSpec . stats . specs ++ // TODO: abstract spec . suite = this } , // Add a hook to the suite addHook : function ( hook , body ) { this . hooks [ hook ] . push ( body ) } , // Add a nested suite addSuite : function ( description , body ) { var suite = new JSpec . Suite ( description , body ) JSpec . allSuites . push ( suite ) suite . name = suite . description suite . description = this . description + ' ' + suite . description this . suites . push ( suite ) suite . suite = this } , // Invoke a hook in context to this suite hook : function ( hook ) { if ( this . suite ) this . suite . hook ( hook ) each ( this . hooks [ hook ] , function ( body ) { JSpec . evalBody ( body , "Error in hook '" + hook + "', suite '" + self . description + "': " ) } ) } , // Check if nested suites are present hasSuites : function ( ) { return this . suites . length } , // Check if this suite has specs hasSpecs : function ( ) { return this . specs . length } , // Check if the entire suite passed passed : function ( ) { return ! any ( this . specs , function ( spec ) { return ! spec . passed ( ) } ) } } ) }
Specification Suite block object.

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