Fork me on GitHub
          
  var Given = require('given');
  var expect = require('expect');

  describe("A Given example", function() {
    var given = undefined;

    beforeEach(function() {
      given = Given(this);
      given({
        name:     function() { return "Alice"; }),
        greeting: function() { return "Hello"; }),
        message:  function() {
          return this.greeting + ' ' + this.name + '!';
        });
      });
    }); 

    it("prints the correct message", function() {
      expect(this.message).toEqual("Hello Alice!");
    });

    it("can redefine the greeting", function() {
      given('greeting', function() { return 'Yo'; });
      expect(this.message).toEqual("Yo Alice!");
    });

    it("can redefine the name to be capitalized", function() {
      given('name', function() { return this.name.toUpperCase()'; });
      expect(this.message).toEqual("Yo ALICE!");
    });
  });
          
        

Given.js

Write DRY specs with lazy setup code

Download v1.0.0!

Given.js: