describe('#clicker',function(){
var handler, event;
beforeEach(function(){
handler = jasmine.createSpy('handles clicks');
event = $.Event('click');
spyOn(event,'preventDefault');
$.jasmine.inject('
');
});
context('when you click the button',function(){
beforeEach(function(){
clicker('.my-button',handler);
$('.my-button').trigger(event);
});
it('triggers the event handler',function(){
expect(handler).toHaveBeenCalledWith(event);
});
it('binds `this` to the jQuery result object',function(){
expect(handler.mostRecentCall.object).toBe('.my-button');
});
it('prevents default browser behavior',function(){
expect(event.preventDefault).toHaveBeenCalled();
});
});
});