Sha256: aa229677c08c2f43bd5d13ff0ef6efd58109943d3902218f88950d6ed2d275a5

Contents?: true

Size: 1008 Bytes

Versions: 12

Compression:

Stored size: 1008 Bytes

Contents

require "spec_helper"

describe JsRoutes, "compatibility with AMD/require.js"  do

  before(:each) do
    evaljs("window.GlobalCheck = {};")
    evaljs("window.define = function (requirs, callback) { window.GlobalCheck['js-routes'] = callback.call(this); return window.GlobalCheck['js-routes']; };")
    evaljs("window.define.amd = { jQuery: true };")
    strRequire =<<EOF
    window.require = function (r, callback) {
      var allArgs, i;

      allArgs = (function() {
        var _i, _len, _results;
        _results = [];
        for (_i = 0, _len = r.length; _i < _len; _i++) {
          i = r[_i];
          _results.push(window.GlobalCheck[i]);
        }
        return _results;
      })();

      return callback.apply(null, allArgs);
    };
EOF
    evaljs(strRequire)
    evaljs(JsRoutes.generate({module_type: 'AMD'}))
  end

  it "should working from require" do
    expect(evaljs("require(['js-routes'], function(r){ return r.inboxes_path(); })")).to eq(test_routes.inboxes_path())
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
js-routes-2.1.2 spec/js_routes/module_types/amd_spec.rb
js-routes-2.1.1 spec/js_routes/module_types/amd_spec.rb
js-routes-2.1.0 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.8 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.7 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.6 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.5 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.4 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.3 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.2 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.1 spec/js_routes/module_types/amd_spec.rb
js-routes-2.0.0 spec/js_routes/module_types/amd_spec.rb