Planning jShoulda 2 -- Syntax change proposal

1 view
Skip to first unread message

Choan Gálvez

unread,
Mar 6, 2009, 10:53:02 AM3/6/09
to jsho...@googlegroups.com
Hi all.

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/>


nlloyds

unread,
Mar 6, 2009, 12:50:45 PM3/6/09
to jShoulda
> * What do you think about the proposed syntax? (it'd be still possible  
> to define aliases and unify runners)

I like it.

>    * publish as jShoulda 2.0, freeze the 1.2.x branch

This.

Thanks,

Nathan

Dr Nic Williams

unread,
Mar 6, 2009, 2:41:26 PM3/6/09
to jsho...@googlegroups.com
Is it still to be called jShoulda if the syntax doesn't include context/should?

My initial reaction was "this is a new project".

Cheers
Nic
--
Dr Nic Williams
Mocra - Premier iPhone and Ruby on Rails Consultants
w - http://mocra.com
e - dr...@mocra.com
p - +61 412 002 126 or +61 7 3102 3237
skype - nicwilliams

Choan Gálvez

unread,
Mar 6, 2009, 2:53:25 PM3/6/09
to jsho...@googlegroups.com
On Mar 6, 2009, at 20:41 , Dr Nic Williams wrote:

> 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

Dr Nic Williams

unread,
Mar 6, 2009, 3:02:06 PM3/6/09
to jsho...@googlegroups.com
I'm not sure. I guess I don't have a problem with context/should structure as it stands now. I'm still very grateful to it that it exists at all :)

Nicolas Alpi

unread,
Mar 7, 2009, 9:32:22 AM3/7/09
to jShoulda
Yea, feel also troubled by the miss of context/should.

I don't think I'll be fan of this syntax.

Nic

On Mar 6, 8:02 pm, Dr Nic Williams <dr...@mocra.com> wrote:
> I'm not sure. I guess I don't have a problem with context/should structure
> as it stands now. I'm still very grateful to it that it exists at all :)
>
>
>
> On Sat, Mar 7, 2009 at 5:53 AM, Choan Gálvez <choan.gal...@gmail.com> wrote:
>
> > On Mar 6, 2009, at 20:41 , Dr Nic Williams wrote:
>
> > > 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
>
> --
> Dr Nic Williams
> Mocra - Premier iPhone and Ruby on Rails Consultants
> w -http://mocra.com

Choan Gálvez

unread,
Mar 7, 2009, 11:13:33 AM3/7/09
to jsho...@googlegroups.com
On Mar 7, 2009, at 15:32 , Nicolas Alpi wrote:

> 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/>

Reply all
Reply to author
Forward
0 new messages