2013-07-23 40 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" }]; 
});