Ove*_*d D 5 ruby-on-rails-3 jasmine
在Rails项目中使用Jasmine时,为了保持我的Jasmine规范中的依赖关系一致,我想在真实页面上完成从cdn中提取jquery.我试着这样做,在我的Jasmine.yml文件中:
helpers:
- http://code.jquery.com/jquery-1.9.1.js
Run Code Online (Sandbox Code Playgroud)
但是,这在查看localhost的源代码时无效:8888我得到:
<script src="/__spec__/http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
你怎么这么正确?
小智 4
正如https://github.com/pivotal/jasmine-gem/issues/135中的回答
我编写了一个帮助程序来加载外部 JavaScript。这不是最好的解决方案(我更喜欢使用配置文件),但它对我有用。
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1480 次 |
| 最近记录: |