searls/jasmine-given — pull request #6 by ronen (2013-03-07 15:58:02+00:00)
Title: Then label

This one's more controversial. In fact, @jimweirich has declined the analogous change for rspec-given. But I'll try it out on you. (And who knows, maybe Jim will relent one day?)

I'm certainly a fan of having the "it" block labeled with the code itself. It's clean, it's clear, it's more DRY than silly things like `it "foo equals 2", -> foo == 2`.

But I find that there are times when, for various reasons, code that expresses a simple idea happens to look ugly in english. For those cases, I do want to be able to fall back to having an english label instead of the code.

So I've added the ability to provide a label to `Then`, which gets passed through to `it`

Then "makes AJAX POST request to create item", -> expect(@ajax_spy).toHaveBeenCalled()
And -> @ajax_spy.mostRecentCall.args[0].type = 'POST'
And -> @ajax_spy.mostRecentCall.args[0].url == "/items"
And -> @ajax_spy.mostRecentCall.args[0].data.item.user_id == userID
And -> @ajax_spy.mostRecentCall.args[0].data.item.name == itemName

(This one requires #4 and #5 to have been merged first, to avoid merge conflicts)