草庐IT

ember-qunit

全部标签

javascript - Ember.js 弃用 registerImplementation 以支持 App.initializer

我正在使用HashLocation的扩展来实现Ember.js的hashbangurl类型。这是代码片段:(function(){varget=Ember.get,set=Ember.set;Ember.Location.registerImplementation('hashbang',Ember.HashLocation.extend({getURL:function(){returnget(this,'location').hash.substr(2);},setURL:function(path){get(this,'location').hash="!"+path;set(t

javascript - 使用单页应用程序的 Rails CSRF 保护( react 、 Angular 、 Ember )

好的。我正式对这个问题失去了理智。让我们使用默认的Rails应用程序(5,但我也尝试使用4默认应用程序)。我正在尝试使用简单的javascript代码将ajaxPOST请求发送到一个Controller操作。在我的ApplicationController中,我有这段代码:classApplicationController它设置一个cookie“X-CSRF-Token”,其值为form_authenticity_token。之后,我可以使用以下代码在我的SPA(单页应用程序)中读取此cookie:functionreadCookie(name){varnameEQ=name+"="

javascript - 在 Rails 中进行 javascript 和 jQuery 测试的 JSpec vs Jasmine vs QUnit

我正在寻找一个与Rails3.0良好集成的javascript单元测试框架谁有使用过上述框架的经验可以分享他们的经验吗?**更新:根据他们的Github存储库,JSpec现已停产:http://github.com/visionmedia/jspec所以这就剩下Jasmine和QUnit 最佳答案 Jasmine与Rails3一起工作得很好,查看如何集成它:http://pivotallabs.com/users/dwfrank/blog/articles/1427-jasmine-in-rails-3

javascript - Ember 路由器记录错误 : "Ember.CollectionView' s content must implement Ember. 阵列”

这里是相当直接的Ember问题,(我希望!)。我有一个简单的Ember数据设置。一个应用程序有多个版本。这是我的应用模型:App.App=DS.Model.extend({name:DS.attr('string'),publicKey:DS.attr('string'),versions:DS.hasMany('App.Version',{key:'version_ids'})});我的路由器相当简单:App.Router=Ember.Router.extend({location:'hash',root:Ember.Route.extend({index:Ember.Route.e

javascript - 如何在 ember.js 中消除嵌套路由的歧义?

我有两个资源,它们都具有相同的子资源:App.Router.map(function(){this.resource('post',function(){this.resource('comments',function(){this.route('new');});});this.resource('product',function(){this.resource('comments',function(){this.route('new');});});});问题在于ember路由器仅根据当前路由和父路由构建路由对象的名称,而不是根据整个层次结构构建路由对象的名称。因此,它尝试将

javascript - 使用转义键取消 Ember TextView 中的操作

当用户在输入字段中按下转义键时,如何让Ember触发Controller操作?给定以下应用程序代码:App=Ember.Application.create();App.IndexRoute=Ember.Route.extend({model:function(){return{foo:"bar"};}});App.IndexController=Ember.ObjectController.extend({actions:{done:function(){console.log("done");},cancel:function(){console.log("cancel");}}}

javascript - Ember.js 错误 : No model was found for 'id' while saving record using ember-data

我正在使用Ember.js和RubyonRails开发简单的CRUD应用程序版本:DEBUG:Ember:1.6.0-beta.3ember.js?body=1:3917DEBUG:EmberData:1.0.0-beta.7+canary.f482da04ember.js?body=1:3917DEBUG:Handlebars:1.3.0ember.js?body=1:3917DEBUG:jQuery:1.11.0RubyonRails4.0.3我正在使用Railscaststutorial非常好,但有些东西发生了很大变化(例如ember-data)。RailscastsEmbert

javascript - 使用 QUnit 对 AJAX 请求进行单元测试

我们正在尝试为JS密集型Web应用程序实现QUnitJavaScript测试。我们正在努力寻找一种方法来成功测试涉及jQueryAJAX请求的方法。例如,我们有下面的构造函数(显然这是一个非常简单的例子):varX=function(){this.fire=function(){$.ajax("someURL.php",{data:{userId:"james"},dataType:"json",success:function(data){//Dostuff}});};};varmyX=newX();myX.fire();我们正在尝试找到一种方法来测试fire方法,最好使用stubU

javascript - QUnit、Sinon.js 和 Backbone 单元测试受挫 : sinon spy appears to fail to detect Backbone Model event callbacks

在下面的单元测试代码中:TestModel=Backbone.Model.extend({defaults:{'selection':null},initialize:function(){this.on('change:selection',this.doSomething);},doSomething:function(){console.log("Somethinghasbeendone.");}});module("Test",{setup:function(){this.testModel=newTestModel();}});test("intra-modeleventbi

javascript - 带有外部 Handlebars 模板的 Ember.js

所以,我对Ember.js有点陌生自从我坚持这个以来已经有几个小时了。我在玩这个bloggrclient我想要完成的是加载那些handlebars来自外部文件的模板。“关于”模板应该在用户点击面板中的关于页面时呈现。这是简短的代码,因此您不必挖掘那么多(我相信对于有经验的用户来说这很容易)里面的模板。html如例子所示SometexttobeshownwhenusersclickABOUT.现在我所做的就是获取x-handlebar远离html的代码页面并将其放置(不带),然后将其放入hbs/about.hbs现在,我在html页面中做了类似的事情。$.ajax({url:'hbs/a