pivotal/jasmine-ajax — pull request #19 by bwillis (2013-01-27 08:29:08+00:00)
Title: Trigger onreadystatechange and enable an afterCreate hook

1. Trigger onreadystatechange when the readyState changed, this was previously only supported when the response was set, ie. readyState=4
2. Allow an afterCreate hook to be set to allow the FakeXMLHttpRequest to be modified.

These two features gave us the ability to set a default response for cases when we wanted all the ajax requests to have the same response. The example is a little contrived for simplicity, but I think it gets the idea across:

```javascript
// setup
jasmine.Clock.useMock();
jasmine.afterCreate = function(xhr){
xhr.onreadystatechange = function(){
if(this.readyState == 2) {
xhr.response({status: 200, responseText: 'nothing changed.'});
}
}
}

// test
poller = new Poller();
poller.start(); // makes multiple ajax requests over time
jasmine.Clock.tick(poller.interval*20);
expect(poller.polledCount).toEqual(20)
```

I think the solution is generic and flexible enough that others might find it useful. Let me know your feedback. Thanks.