2013-07-23 42 views
2

我想用visit帮手,以集成测试以下路线:在运行循环集成测试灰烬数据模型

App.IndexRoute = Em.Route.extend 
    model: -> 
     App.Movies.find "The Godfather" 

但我的测试不及格,我得到:

assertion failed: You have turned on testing mode, which disabled the run-loop's autorun. 
You will need to wrap any code with asynchronous side-effects in an Ember.run 

不幸的是,它包裹起来像这样没有帮助:

App.IndexRoute = Em.Route.extend 
    model: -> 
     Em.run => 
      App.Movies.find "The Godfather" 

(我还裹着@App = Em.Application.create()

将代码包装到运行循环中的正确方法是什么?

我正在使用rc.5与Karma。

回答

-1

如何为测试构建数据?这是应该包装在Ember.run中的那部分(或设置属性)。

使用FixtureAdapter,你应该有这样的事情:

Ember.run(function() { 
    App.Movie.FIXTURES=[{ name: "the Godfather" }, { name: "Apocalypse Now" }]; 
});