link
vows-fluentA small layer of sugar on top of vows
link
Blog postlink
A small fluent API around vows.Inspired by prenup and vows-bdd
link
Why don't you use prenup ?Prenup is great but it only abstract contexts. So I needed to extend it to abstract Batches and Suites.
After looking at the code it wasn't really open to extension so I wrote my own instead.
I also changed the API to match vows more directly.
link
Why don't you use vows-bdd ?The vows-bdd has a similar chaining but uses a foreign API that doesn't match vows.
link
DocumentationShould be straight forward. Consider this your documentation.
If there are any issue feel free to raise an issue.
link
ExampleTurns the clumsy
vows.describe("Arithmetic Test").addBatch({
"2 into 6" : {
topic : function () { return 6/2; },
"is a number" : function (topic) { assert.isNumber(topic); },
"equals 3" : function (topic) { assert.equal(topic, 3); }
},
"123" : {
topic : 123,
"is a number" : function (topic) { assert.isNumber(topic); },
"equals 123" : function (topic) { assert.equal(topic, 123); },
"divided by 10" : {
topic : function (topic) { return topic/10; },
"equals 12.3" : function (topic) { assert.equal(topic, 12.3); }
}
},
"1 plus 3" : {
topic : function () { return 1 + 3; },
"is a number" : function (topic) { assert.isNumber(topic); },
"equals 4" : function (topic) { assert.equal(topic, 4); },
"subtract 5" : {
topic : function (topic) { return topic -5; },
"is a number" : function (topic) { assert.isNumber(topic); },
"equals -1" : function (topic) { assert.equal(topic, -1); },
"times 2" : {
topic : function (topic) { return topic *2; },
"is a number" : function (topic) { assert.isNumber(topic); },
"equals -2" : function (topic) { assert.equal(topic, -2); }
},
"times 0" : {
topic : function (topic) { return topic *0; },
"equals 0" : function (topic) { assert.equal(topic, 0); }
}
}
}
}).export(module);
Into the chain declarative
suite("Arithmetic Test").batch()
.context("2 into 6")
.topic(function() { return 6 / 2 })
.vow("is a number", function (topic) { assert.isNumber(topic); })
.vow("equals 3", function (topic) { assert.equal(topic, 3); })
.batch()
.context("123")
.topic(123)
.vow("is a number", function(topic) { assert.isNumber(topic); })
.vow("equals 123", function(topic) { assert.equal(topic, 123); })
.context("divided by 10")
.topic(function(topic) { return topic / 10; })
.vow("equals 12.3", function (topic) { assert.equal(topic, 12.3); })
.batch()
.context("1 plus 3")
.topic(function() { return 1 + 3; })
.vow("is a number", function(topic) { assert.isNumber(topic); })
.vow("equals 4", function(topic) { assert.equal(topic, 4); })
.context("subtract 5")
.topic(function(topic) { return topic - 5; })
.vow("is a number", function (topic) { assert.isNumber(topic); })
.vow("equals -1", function(topic) { assert.equal(topic, -1); })
.context("times 2")
.topic(function(topic) { return topic * 2; })
.vow("is a number", function(topic) { assert.isNumber(topic); })
.vow("equals -2", function(topic) { assert.equal(topic, -2); })
.parent()
.context("times 0")
.topic(function (topic) { return topic * 0; })
.vow("equals 0", function(topic) { assert.equal(topic, 0); })
.suite()
.end().export(module);