I think there are some problems with the current syntax of jShoulda:
* Requires putting methods on the global namespace
* Prone to syntax errors (every time I move an example I get one of
this)
* Too weird for not-so-advanced javascript coders
Then I thought about chaining, drank some beer, played rumba, return
home, branched... and this is the proposed new syntax:
jShoulda(config) // returns a root context object
.before(fn) // as many as you want
.after(fn) // as many as you want
.describe('context name') // returns a context object
.it('example name', fn) // returns the context object
.end() // returns the parent context
.run() // setup defined tests, returns the root context object
You can compare the current and the proposed new syntax at <http://gist.github.com/74905
>
Benefits of the new syntax:
* Only the `jShoulda` method would be in the global namespace
* You can save "states" to variables and work on them
* Less prone to syntax errors (at least for me)
* Not so weird (in my opinion)
* Library is much more simple (and runs lighter)
Drawbacks:
* Slightly more verbose
* No backwards compatibility. Zero. Nada.
Then of course, I have some questions:
* What do you think about the proposed syntax? (it'd be still possible
to define aliases and unify runners)
* The change is too drastical. Previous syntax would not be supported
anymore. So I see two options:
* publish as jShoulda 2.0, freeze the 1.2.x branch
* leave the jShoulda library as is, publish this "version" as a
separate new project
* ???
Please, comment.
--
Choan Gálvez
<choan....@gmail.com>
<http://choangalvez.nom.es/>
> Is it still to be called jShoulda if the syntax doesn't include
> context/should?
> My initial reaction was "this is a new project".
Good point.
What about the new syntax? Would you prefer the brand-new-still-
unnamed-tool or jShoulda?
--
Choan
> Yea, feel also troubled by the miss of context/should.
They aren't gone. In fact, aliasing methods are being improved.
> I don't think I'll be fan of this syntax.
Then you can still use jShoulda ;)
The new syntax is being implemented in a brand new project: SugarTest <http://github.com/choan/sugar_test/
>.
I'll post details as soon as I consider the new library is worth it.
--
Choan
<http://choangalvez.nom.es/>