How can you include a javascript files from a CDN in Jasmine?
jasmine, ruby-on-rails-3
Solution
as answered in https://github.com/pivotal/jasmine-gem/issues/135
I wrote a helper to load external javascripts. It's not the best solution (i would prefer config file use) but it works for me.
var head = document.getElementsByTagName('head')[0];
var jQueryScript = document.createElement('script');
jQueryScript.setAttribute('type', 'text/javascript');
jQueryScript.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
head.appendChild(jQueryScript);
Problem
When using Jasmine in a Rails project, to keep the dependencies consistent in my Jasmine specs, I want to pull jquery from a cdn as is done on the real page. I try to do that like so, in my Jasmine.yml file: ``` helpers: - http://code.jquery.com/jquery-1.9.1.js ``` However, this never works, as when viewing the source of the localhost:8888 I get: ``` <script src="/__spec__/http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> ``` How do you this correctly?