Sha256: e01f04ed038fab631f272defeb4956dd16649acbd98e8373011264bb014689c5

Contents?: true

Size: 1.25 KB

Versions: 39

Compression:

Stored size: 1.25 KB

Contents

getJasmineRequireObj().AjaxRequestStub = function() {
  function RequestStub(url, stubData, method) {
    var normalizeQuery = function(query) {
      return query ? query.split('&').sort().join('&') : undefined;
    };

    if (url instanceof RegExp) {
      this.url = url;
      this.query = undefined;
    } else {
      var split = url.split('?');
      this.url = split[0];
      this.query = split.length > 1 ? normalizeQuery(split[1]) : undefined;
    }

    this.data = normalizeQuery(stubData);
    this.method = method;

    this.andReturn = function(options) {
      this.status = options.status || 200;

      this.contentType = options.contentType;
      this.responseText = options.responseText;
    };

    this.matches = function(fullUrl, data, method) {
      var matches = false;
      fullUrl = fullUrl.toString();
      if (this.url instanceof RegExp) {
        matches = this.url.test(fullUrl);
      } else {
        var urlSplit = fullUrl.split('?'),
            url = urlSplit[0],
            query = urlSplit[1];
        matches = this.url === url && this.query === normalizeQuery(query);
      }
      return matches && (!this.data || this.data === normalizeQuery(data)) && (!this.method || this.method === method);
    };
  }

  return RequestStub;
};

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/requestStub.js
upjs-rails-0.10.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.10.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.10.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.10.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.10.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.10.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.9.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.9.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.8.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.8.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.8.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.8 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.7 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.6 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js
upjs-rails-0.7.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/requestStub.js