Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Weird behavior in jasmine-node

View README.markdown

Weird behavior in jasmine-node

I'm using node 0.8 with jasmine-node, coffee-script and backbone in a project with this folder structure:

<project root>
 ` fares/
 | ` base.coffee
 | ` import.coffee
 | ` import_list.coffee
 ` spec/
   ` fares/
     ` base.spec.coffee
     ` import_list.spec.coffee

And I have the weird situation of having green tests when calling from a specific folder and red tests from another.

If I run:

jasmine-node --coffee spec/fares/import_list.spec.coffee

The test passes. However, if I run the whole suite:

jasmine-node --coffee spec/

The test fails.

Check the failing logs where I console.loged the result of require "./import" and found to be an empty object ({}) rather than the Import class.

I don't know why this is happening, do you have any clue on this weird behavior? I appreciate your help, thank you.

View README.markdown
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Backbone = require "backbone"
Import = require "./import"
 
class ImportList extends Backbone.Collection
model: Import
 
initialize: ->
@bind "change:end", @importChanged, @
@bind "destroy", @updateImports, @
 
importChanged: (_import, collection, options) ->
@appendImport _import.get("end") + 1 if @isLast(_import) is true
 
appendImport: (start, end = Import.MAX) ->
@add new Import start: start, end: end
 
updateImports: (_import, collection, options ) ->
@at(options.index - 1).set "end" : _import.get "end"
@remove @at options.index
 
isLast: (_import) ->
@indexOf(_import) == (@length - 1)
 
module.exports = ImportList if module?
if window? and window.define?
define [ "backbone", "fares/import" ], (Backbone, Import) -> ImportList
View README.markdown
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ImportList = require "../../fares/import_list"
Import = require "../../fares/import"
 
describe "ImportList", ->
import_list = null
 
beforeEach ->
import_list = new ImportList
import_list.add new Import start: 1
 
describe "when changing the endpoint of one import", ->
beforeEach ->
import_list.first().set "end" : 2
 
it "adds one import", ->
expect(import_list.length).toEqual 2
View README.markdown
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
..F
 
Failures:
 
1) adds one import
Message:
TypeError: object is not a function
Stacktrace:
TypeError: object is not a function
at ImportList.appendImport (/Users/josemota/projects/ICAROUS/ICAROUS.PORTALADMIN/src/main/webapp/js/fares/import_list.coffee:35:23)
at ImportList.importChanged (/Users/josemota/projects/ICAROUS/ICAROUS.PORTALADMIN/src/main/webapp/js/fares/import_list.coffee:27:21)
at ImportList.Backbone.Events.trigger (/usr/local/lib/node_modules/backbone/backbone.js:163:27)
at ImportList._.extend._onModelEvent (/usr/local/lib/node_modules/backbone/backbone.js:844:20)
at Import.Backbone.Events.trigger (/usr/local/lib/node_modules/backbone/backbone.js:170:27)
at Import._.extend.change (/usr/local/lib/node_modules/backbone/backbone.js:473:14)
at Import._.extend.set (/usr/local/lib/node_modules/backbone/backbone.js:314:33)
at null.<anonymous> (/Users/josemota/projects/ICAROUS/ICAROUS.PORTALADMIN/src/main/webapp/js/spec/fares/import_list.spec.coffee:21:36)
at jasmine.Block.execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1001:15)
at jasmine.Queue.next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
 
2) adds one import
Message:
Expected 1 to equal 2.
Stacktrace:
Error: Expected 1 to equal 2.
at new jasmine.ExpectationResult (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:102:32)
at null.toEqual (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1171:29)
at null.<anonymous> (/Users/josemota/projects/ICAROUS/ICAROUS.PORTALADMIN/src/main/webapp/js/spec/fares/import_list.spec.coffee:26:43) at jasmine.Block.execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1001:15)
at jasmine.Queue.next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
at jasmine.Queue.start (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
at jasmine.Spec.execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2070:14)
at jasmine.Queue.next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
at jasmine.Queue.start (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
at jasmine.Suite.execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2215:14)
 
Finished in 0.01 seconds
3 tests, 5 assertions, 2 failures

Hi,

did you find the solution for this particular problem? I am having the same issue using coffescript + jasmine and gulp.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.