         .whenCalledWith('another_custom_path', a: 2).shouldReturn 'hmm'
         .whenCalledWith('another_custom_path', a: 1, b: 2).shouldReturn 'another string'
 
-      $.getJSON('custom_path', a: 1).done (@result) =>
-      expect(@result).to.be.eql 'pish-pish'
+      $.getJSON('custom_path', a: 1).done @spy
+      expect(@spy).to.be.calledWith 'pish-pish'
 
-      $.getJSON('another_custom_path', a: 2).done (@result) =>
-      expect(@result).to.be.eql 'hmm'
+      $.getJSON('another_custom_path', a: 2).done @spy
+      expect(@spy).to.be.calledWith 'hmm'
 
-      $.getJSON('another_custom_path', a: 1, b: 2).done (@result) =>
-      expect(@result).to.be.eql 'another string'
+      $.getJSON('another_custom_path', a: 1, b: 2).done @spy
+      expect(@spy).to.be.calledWith 'another string'
 
   describe 'MockApi#restore', ->
     it 'restores mocked method', ->

  describe 'MockApi#shouldReturn', ->
    it 'makes mocked method to return specified value on resolving (when called)', ->
      @mockedMethodApi.shouldReturn 'ololo'
      $.getJSON().done (@result) =>
      expect(@result).to.be.eql 'ololo'

    it 'makes mocked method to return callback result on resolving if callback provided', ->
      @mockedMethodApi.shouldReturn -> 'ololo'
      $.getJSON().done (@result) =>
      expect(@result).to.be.eql 'ololo'

  describe 'MockApi#shouldSucceed', ->
    it 'makes mocked method to return specified value on resolving (when called)', ->
      @mockedMethodApi.shouldSucceed 'ololo'
      $.getJSON().done (@result) =>
      expect(@result).to.be.eql 'ololo'

    it 'makes mocked method to return callback result on resolving if callback provided', ->
      @mockedMethodApi.shouldSucceed -> 'ololo'
      $.getJSON().done (@result) =>
      expect(@result).to.be.eql 'ololo'

  describe 'MockApi#shouldFail', ->
    it 'makes mocked method to return specified value on rejecting (when called)', ->
      @mockedMethodApi.shouldFail 'ololo'
      $.getJSON().fail (@result) =>
      expect(@result).to.be.eql 'ololo'

    it 'makes mocked method to return callback result on rejecting if callback provided', ->
      @mockedMethodApi.shouldFail -> 'ololo'
      $.getJSON().fail (@result) =>
      expect(@result).to.be.eql 'ololo'

  describe 'MockApi#whenCalledWith', ->
    it 'makes mocked method to return specified value when called with specified string argument', ->


describe 'MockApi', ->
  beforeEach ->
    @sourceMethod = $.getJSON
    @mockedMethodApi = new MockApi($, 'getJSON')
    @spy = sinon.spy()

  afterEach ->
    @mockedMethodApi.restore()
    @spy.reset()

  it 'mocks source method', ->
    expect($.getJSON).to.not.be.equal @sourceMethod
