中列出。
rake jasmine我所有的测试都通过浏览器。
使用耙茉莉,2个规格失败了:
TypeError: undefined is not a function (evaluating 'expect(player).not.toBePlaying(song)') in http://localhost:36091/__spec__/PlayerSpec.js (line 28)
我已经配置了我的 spec/javascripts/support/jasmine.yml
文件,以便它具有
src_files:
- src/Player.js
- src/Song.js
spec_files:
- '**/*[sS]pec.js'
src_dir:
spec_dir: spec
src/Song.js
有:
function Song() {
...
为什么rake jasmine:ci
在这两个示例中失败?
第一个失败的代码是:
it("should be able to play a Song", function() {
player.play(song);
expect(player.currentlyPlayingSong).toEqual(song);
//demonstrates use of custom matcher
expect(player).toBePlaying(song); # <-- error here
});
Song.js
似乎已经加载了,因为如果我删除了所有5个示例失败。
我需要自定义匹配器toBePlaying
我能够通过在spec/javascripts/support/jasmine.yml
文件中更改它来获得所有规格:
src_files:
- src/Player.js
- src/Song.js
- spec/SpecHelper.js # <--- Added to include the custom helper 'toBePlaying'
我尝试将其添加到spec_files
部分,但需要在src_files