Sha256: 508b7b9aa36c1482bbfaaca8ca79172040671db8624cc0a09876a9faf31c7786

Contents?: true

Size: 1.11 KB

Versions: 39

Compression:

Stored size: 1.11 KB

Contents

getJasmineRequireObj().MockAjax = function($ajax) {
  function MockAjax(global) {
    var requestTracker = new $ajax.RequestTracker(),
      stubTracker = new $ajax.StubTracker(),
      paramParser = new $ajax.ParamParser(),
      realAjaxFunction = global.XMLHttpRequest,
      mockAjaxFunction = $ajax.fakeRequest(global, requestTracker, stubTracker, paramParser);

    this.install = function() {
      global.XMLHttpRequest = mockAjaxFunction;
    };

    this.uninstall = function() {
      global.XMLHttpRequest = realAjaxFunction;

      this.stubs.reset();
      this.requests.reset();
      paramParser.reset();
    };

    this.stubRequest = function(url, data, method) {
      var stub = new $ajax.RequestStub(url, data, method);
      stubTracker.addStub(stub);
      return stub;
    };

    this.withMock = function(closure) {
      this.install();
      try {
        closure();
      } finally {
        this.uninstall();
      }
    };

    this.addCustomParamParser = function(parser) {
      paramParser.add(parser);
    };

    this.requests = requestTracker;
    this.stubs = stubTracker;
  }

  return MockAjax;
};

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
upjs-rails-0.11.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.10.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.9.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.9.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.8.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.8.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.8.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.8 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.7 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.6 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js
upjs-rails-0.7.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/mockAjax.js