public
Description: Mocking and stubbing in JavaScript.
Homepage:
Clone URL: git://github.com/Manfred/moksi.git
moksi /
README.markdown

Moksi

Moksi is a stubbing and mocking library for JavaScript.

var Person = {
  name: function() {
    return 'Alice';
  },
  age: function() {
    return 28;
  }
}

// Stub the person's name.
Moksi.stub(Person, 'name', function() {
  return 'Bob';
});
Person.name() == 'Bob';

// Expect age to be called
Moksi.expects(Person, 'age');
Moksi.rejects(Person, 'name');
Person.age();
Moksi.assertExpectations(this);

// Revert all stubs and expectations
Moksi.revert(); 
Person.name() == 'Alice';