Wednesday, 15 April 2015

ruby on rails 3 - How can you include a javascript files from a CDN in Jasmine? -



ruby on rails 3 - How can you include a javascript files from a CDN in Jasmine? -

when using jasmine in rails project, maintain dependencies consistent in jasmine specs, want pull jquery cdn done on real page. seek so, in jasmine.yml file:

helpers: - http://code.jquery.com/jquery-1.9.1.js

however, never works, when viewing source of localhost:8888 get:

<script src="/__spec__/http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

how correctly?

as answered in https://github.com/pivotal/jasmine-gem/issues/135

i wrote helper load external javascripts. it's not best solution (i prefer config file use) works 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);

ruby-on-rails-3 jasmine

No comments:

Post a Comment