OO style examples for oojspec (JavaScript)

by rosenfeld

HTML

<script src="http://oojspec.herokuapp.com/assets/oojspec.js"></script>
<link rel="stylesheet" href="http://oojspec.herokuapp.com/assets/oojspec.css">

JavaScript

oojspec.exposeAll();

describe({
      description: 'Plain Object binding',
      dialog: {dialog: true},
      runSpecs: function(){ this.example('an example', this.sampleExample); },
      sampleExample: function(){ this.assert(this.dialog.dialog); }
});

describe('Bare description', {
      bare: true,
      dialog: {dialog: true},
      runSpecs: function(s){ s.example('an example', this.sampleExample); },
      sampleExample: function(s){ s.assert(this.dialog.dialog); }
});

// or just make use of this in regular describe blocks:

describe("Regular describe", function(){
    this.example("'this' is propagated", function(){
        this.expect(this.helper()).toBe(1);
    });
    this.helper = function(){ return 1; };
});

describe("Regular describe with bare set-up", function() {
    this.bare = true;
    this.timeout = 100; // override default timeout for waitsFor blocks
    this.example("'this' is propagated but DSL is not injected", function(s){
        s.expect(this.timeout).toBe(100);
        s.refute(this.expect)
    });
});

oojspec.runSpecs();