オブジェクトがあるとします
var myObject = Ember.Object.create({
enable: function(){
//a method which has a lot of calculations and returns a boolean
}.property("someDependency"),
disable: Ember.computed.not("enable")
})
enable
プロパティを個別にテストしますが、プロパティを個別にテストしたいので、テストケースを単純にするためdisable
にスタブを作成したいだけです。enable
私は試した
myObject.set("enable", true)
しかし、セッターを定義する必要があるため、これは正しくありません (計算されたすべてのプロパティには当てはまりません)。
sinon.stub(myObject, "enable")
も失敗しEmber.computed
ますobject
が、sinon は 2 番目の引数としてメソッドを必要とします
それで、問題はstub
、 ember 0.9.8 で計算されたプロパティの正しい方法は何ですか?