JSpec Googleグループにメッセージを投稿する試みが2回失敗したようですが、代わりにここに投稿しています。
JSpecが特定の種類のテスト(以下)で無限再帰ループに入るのに問題があります。何か案は?コードに何か問題がありますか、それともJSpecですか?RubyGem経由でJSpec2.11.2を実行しています。
エラーは「RangeError:最大呼び出しスタックサイズを超えました」です。(Safari)および「InternalError:再帰が多すぎます」(FF / Mac)。Firebugコンソールを使用して、エラーなしでアイテムをルームに追加できます。
問題を再現するには、「jspecinittest」を使用してテンプレートjspecプロジェクトを作成します。次に、次のファイルを次のように編集します。
yourlib.core.js
var Game = {};
Game.item = function () {
var result = {
name : 'Undefined',
room : null
}
return result;
};
Game.room = function () {
var result = {
items : [],
addItem : function (name) {
var item = Game.item();
item.name = name;
item.room = this;
this.items.push(item);
return item;
}
};
return result;
};
spec.core.js
describe 'Room'
before_each
room = Game.room()
end
describe 'addItem()'
before_each
potion = room.addItem('Potion')
key = room.addItem('Key')
end
//this is fine
it 'should return two different items'
key.should_not.be potion
end
//InternalError: too much recursion
it 'should not give recursion error'
key.should.be potion
end
end
end