2017-05-05 40 views
0

随着耙茉莉花我所有的测试通过浏览器。为什么耙茉莉花通过,但耙茉莉花:ci失败TypeError:undefined不是函数?

随着耙茉莉,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例失败。

回答

0

我需要自定义匹配器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