vows-fluent

0.2.0 • Public • Published

vows-fluent link

A small layer of sugar on top of vows

Blog post link

Testing with vows-fluent

A small fluent API around vows. link

Inspired by prenup and vows-bdd

Why don't you use prenup ? link

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.

Why don't you use vows-bdd ? link

The vows-bdd has a similar chaining but uses a foreign API that doesn't match vows.

Documentation link

Annotated Source Code

Should be straight forward. Consider this your documentation.

If there are any issue feel free to raise an issue.

Example link

Turns 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);

Readme

Keywords

none

Package Sidebar

Install

npm i vows-fluent

Weekly Downloads

1

Version

0.2.0

License

none

Last publish

Collaborators

  • raynos