GitXplorerGitXplorer
a

tclspec

public
15 stars
3 forks
1 issues

Commits

List of commits on branch master.
Unverified
f45b7c75c2b4deed2d606970d22cb9f27c44f960

Merge commit '6753bc586300f70a63cf6ae59829b40e25030145'

aarthurschreiber committed 11 years ago
Unverified
6753bc586300f70a63cf6ae59829b40e25030145

Squashed 'vendor/tcloo-ext/' changes from d40f439..1e7b835

aarthurschreiber committed 11 years ago
Unverified
2386b3c0c3266603398b3be5a34969f15403a186

Fix a mistake I introduced during merging.

aarthurschreiber committed 11 years ago
Unverified
2b963007b8a2bc7181e6dd3a146ab37c3a2bf5d3

Merge branch 'tclspec/backport' into tclspec/master

aarthurschreiber committed 11 years ago
Unverified
a775326048fbb353e42adef591594c5976a8b5fd

Squashed 'vendor/tcloo-ext/' changes from 009ed79..d40f439

aarthurschreiber committed 11 years ago
Unverified
03445db150cc87e1b2f6f7cebb27ffb127cbe7f4

Merge commit 'a775326048fbb353e42adef591594c5976a8b5fd'

aarthurschreiber committed 11 years ago

README

The README file for this repository.

TclSpec Build Status

Behaviour Driven Development for Tcl

Overview

TclSpec is a Behaviour Driven Development (BDD) Framework for the Tcl language.

It is based on RSpec, a BDD Framework for Ruby.

Prerequisites

Installation

Put the tclspec folder into one of the folders denoted in your Tcl's $auto_path.

Basic Usage

TclSpec allows you to describe the behaviour of your code using a structure of describe and it blocks.

Basic Structure

describe Order {
    it "sums the prices of its line items" {
        set order [Order new]
        $order add_entry [LineItem new -item [Item new -price "1.11"]]
        $order add_entry [LineItem new -item [Item new -price "2.22" -quantity 2]]

        expect [$order total] to equal 5.55
    }
}

Nested Groups

Groups can be nested using example or context keywords:

describe Order {
    context "with no items" {
        it "behaves one way" {
            # ...
        }
    }

    context "with one item" {
        it "behaves another way" {
            # ...
        }
    }
}

Matchers

TclSpec comes with a list of built in matchers that you can use to express expected outcomes inside your specifications.

Equivalence

expect $actual to equal $expected

Comparisons

expect $actual to be >  $expected
expect $actual to be >= $expected
expect $actual to be <= $expected
expect $actual to be <  $expected
expect $actual to be_within $delta of $expected

Truthiness

expect $actual to be true
expect $actual to be false

Expecting Errors

expect { ... } to raise_error
expect { ... } to raise_error -code SomeErrorCode
expect { ... } to raise_error -message "Some error message"
expect { ... } to raise_error -code SomeErrorCode -message "Some error message

Stubbing and Mocking

Tclspec includes stubbing and mocking functionality for plain Tcl procs and nx objects.

Stubbing

Test stubs allow you to switch out the implementation of a proc during the runtime of an example. After the example has been executed, the test stub will be cleaned up and removed.

Stubs should be used if you want to force specific code behaviour in your examples or if you want to prevent the call to the original implementation of a procedure in your test case.

Tcl

stub_call "::roll_die" -and_return 3

nx

$die stub "roll" -and_return 3

The tclspec Command

In the bin folder, you can find the tclspec executable, which is used to run tclspec. Calling tclspec without any arguments will execute all spec files located in the spec folder in the current working directory. Additionally, you can either pass individual files or folders to run.

Contributing

If you want to contribute to TclSpec, please open a ticket in the Github Issue Tracker and let me know what you want to work on, so I can provide you with feedback upfront.

If you have changes/patches, please open a Github Pull Request so that I can review your changes. I'll try to get back to you as soon as passible with my comments.