quangv / mocha-cakes

(inactive) BDD mocha test framework add-on, stories with Cucumber style Given/When/Then syntax for Node.js
MIT License
126 stars 6 forks source link

Help with mocha-cakes #4

Closed ericchaves closed 12 years ago

ericchaves commented 12 years ago

Hi Quang,

I've found your mocha-cakes library and I'm trying to use it with a sample node.js project but since I'm new to node.js I'm facing some troubles and therefore I'd like to ask you for some help and directions, if thats ok to you.

My project have a model and a mocha test running ok. I'm now trying to add a new test written in GWT grammar instead of regular BDD, using your's mocha-cakes. I declared mocha-cakes in the project package.json and have it installed for the project (not globally). I'm writing the tests in javascript and not coffeescript since I'm not very good at coffee yet.

If run the tests without requiring the mocha-cake library it fails because feature is not defined :

ReferenceError: feature is not defined
    at Object.<anonymous> (/Users/ericchaves/Projects/nodejs/bouncer/test/users.js:33:1)

If I require mocha-cakes then the compilation fails due to use of a reserved word interface:

SyntaxError: In /Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/cakes.coffee, reserved word "interface" on line 9
    at SyntaxError (unknown source)
    at Lexer.error (/Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/node_modules/coffee-script/lib/coffee-script/lexer.js:686:13)
    at Lexer.identifierToken (/Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/node_modules/coffee-script/lib/coffee-script/lexer.js:88:16)
    at Lexer.tokenize (/Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/node_modules/coffee-script/lib/coffee-script/lexer.js:35:19)
    at /Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/node_modules/coffee-script/lib/coffee-script/coffee-script.js:43:32
    at Object..coffee (/Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/node_modules/coffee-script/lib/coffee-script/coffee-script.js:19:17)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/ericchaves/Projects/nodejs/bouncer/node_modules/mocha-cakes/index.js:2:18)

Could you point me what am I doing wrong here? How should I be running this tests?

Thanks in advance,

Eric

quangv commented 12 years ago

If I require mocha-cakes then the compilation fails due to use of a reserved word interface:

How are you requiring MC ?

Can you give me an example of a failing mocha-cakes test file?

Example: mocha-test.coffee

require 'mocha-cakes'

Feature "Test", ->

    Scenario "Do It", ->
        Given "Dog", ->
        When "Cat", ->
        Then "Yes", ->

This simple test can be run with...

mocha -R spec mocha-test.coffee

*Note: you can also require 'mocha-cakes' with the command line instead of in-source with command mocha -R spec -r mocha-cakes mocha-test.coffee

ericchaves commented 12 years ago

Hi Quang,

I was actually using the example in the readme. In fact I just saved it in a file under the test directory and tried to run it with mocha specifing the cross-compiler option for coffeescript.

Maybe the conflict may be with some package installed in my project but unfortunelly I already delete it (it was temporary project for learning purposes only). I'll try to redo it later on.

Cherrs,

Eric

quangv commented 12 years ago

Okay I'll close this for now. Good Luck!

Note: What OS are you using? Mocha-Cakes has only been tested on Linux, Windows just got Node.js support and I hear a lot of things could be buggy.