Sha256: 4b0970177a78b2fc506ec2246221ff2f241ab432de84f02e88e89297a5c43eb1

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# =require modules

TIMEOUT = 500 # ms - Used to be 300, but FF was too slow
extendClass 'specs.oojspec.AjaxHelpers', ->
  ajaxServer = null
  initialize: (fakeAjaxServer, options = {})->
    ajaxServer = fakeAjaxServer
  ajaxSettings: -> ajaxServer.ajaxSettings()
  waitsForAjaxRequest: (message = "An AJAX call was expected", \
                        timeout = @timeout or TIMEOUT, extraCondition)->
    @waitsFor message, timeout, ->
      ajaxServer.ajaxCallbacksQueue.length and (not extraCondition or extraCondition.call this)
  waitsForAjaxRequestAnd: (condition, message, timeout)->
    @waitsForAjaxRequest(message, timeout, condition)
  nextRequest: (url, method, format)->
    @checkRequestSettings(url, method, format)
    ajaxServer.processNextRequest()
  checkRequestSettings: (url, method, format)->
    s = @ajaxSettings()
    @expect(s.url).toBe url unless url is undefined
    @expect(s.type).toBe method unless method is undefined
    @expect(s.dataType).toBe format unless format is undefined
  ignoreRequest: (url, method, format)->
    @checkRequestSettings(url, method, format)
    ajaxServer.ignoreNextRequest()
  ignoreAllRequest: -> ajaxServer.ignoreAllRequest()

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
oojs-0.3.0 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.2.3 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.2.2 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.2.1 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.2.0 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.1.1 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee
oojs-0.1.0 lib/assets/javascripts/oojspec_helpers/ajax_spec_helpers.js.coffee