konocha 3.2.3,rails 4.0.2。我想在我的Ember View中存根didInsetElement方法
我用
sinon.stub(App.ToyBoxView," didInsertElement")
但我得到
TypeError: Attempted to wrap undefined property didInsertElement as function
at Object.wrapMethod (http://localhost:3500/assets/sinon.js?body=1:522:23)
at Object.stub (http://localhost:3500/assets/sinon.js?body=1:1662:22)
at Context.<anonymous> (http://localhost:3500/assets/aptp/routes/application_route_spec.js?body=1:12:22)
at invoke (http://localhost:3500/assets/ember-mocha-adapter.js?body=1:60:8)
at Context.<anonymous> (http://localhost:3500/assets/ember-mocha-adapter.js?body=1:52:11)
at Hook.Runnable.run (http://localhost:3500/assets/mocha.js:4319:15)
at next (http://localhost:3500/assets/mocha.js:4609:10)
at http://localhost:3500/assets/mocha.js:4626:5
at timeslice (http://localhost:3500/assets/mocha.js:5733:27)
我的观点:
App.ToyBoxView = Ember.View.extend Ember.ViewTargetActionSupport,
properties..
didInsertElement: ->
console.log "Something"
答案 0 :(得分:0)
您需要在didInsertElement
上定义App.ToyBoxView
,它只存在于实例上,而不存在于类型定义本身上。