Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Javascript mocking and stubbing framework
JavaScript
branch: 0.2

This branch is 41 commits ahead of master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
README.rdoc
Rakefile
TODO

README.rdoc

espionage

A javascript mocking/stubbing framework

stubbing

var obj = {};

obj.stub("foo")
obj.hasOwnProperty("foo") #=> true

obj.stub("foo", 1);
obj.foo() # => 1

obj.stub("bar", 2);
obj.bar() # => 2

obj.stub("foo", function(x) { return x; });
obj.foo()        # => undefined
obj.foo(1)       #=> 1
obj.foo("hello") #=> "hello"

mock expectations / test spies:

var obj = {};

spyOn(obj, function() {
  obj.foo();
  spy.intercepted(obj, "foo") #=> true
});

spyOn(obj, function() {
  obj.foo();
  spy.intercepted(obj, "bar") #=> false
});
Something went wrong with that request. Please try again.