Why does rake jasmine pass but rake jasmine:ci fails with TypeError: undefined is not a function?

Why does rake jasmine pass but rake jasmine:ci fails with TypeError: undefined is not a function?

有了 rake jasmine,我所有的测试都在浏览器中通过了。

使用 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

中列出