Search code examples
javascriptjasminerakejasmine2.0

Why can't jasmine find my source code with rake jamine:ci?


I can rake jasmine to run the server and then visit

http://localhost:8888/SpecRunner.html

and I get

enter image description here

but when I do rake jasmine:ci 0 specs are found. I moved PlayerSpec.js to spec/javascripts/ and they were found but now they all fail with errors such as

Player should be able to play a Song

ReferenceError: Can't find variable: Player in http://localhost:45147/__spec__/PlayerSpec.js (line 6)
...

It seems that the src/Player.js file isn't being used as that is where Player is defined, i.e.

function Player() {
}
Player.prototype.play = function(song) {
...

Where should I be putting the source file Player.js as src isn't working ?
I've tried putting the Player.js file in spec/ and spec/javascripts/ but it didn't help, same error.

I tried inserting the Player function at the top of the spec file but that didn't help, same error.


Solution

  • This is controlled by the spec/javascripts/support/jasmine.yml file

    I was able to get rake jasmine:ci to use the same source and spec files as used by rake jasmine by updating the jasmine.yml file, specifically

    src_files:
      - src/Player.js
      - src/Song.js
    

    and

    # spec_dir: Example spec/javascripts
    #
    spec_dir: spec
    

    This solved most of my issues. 2 specs are still failing as they aren't finding Song which exists in src and is included as shown but that is a separate issue I am looking into.