RTFSpec is now in Alpha

As said before I am writing a testing framework for Clojure. It started as a fork of the Fact framework but eventually I decided to try some ideas that arose in a conversation with Fábio and Rob: use RFC-2119 semantics to describe tests. RTFSpec is my take on this approach.

Here is an example from the (pretty inexistent) documentation:

 (use 'rtfspec)

(spec "List Comprehensions"
      (must "return a list applying the given function"
	    (= (list 11 12 13 14 15)
	       (for [a (list 1 2 3 4 5)] (+ 10 a))))

      (must "include elements that are not matched by the :while clause"
		(empty?
		   (for [a (list 1 2 3 4 5) :when (= a (+ 10 a))] a))))

And the output using ant:

[rtfspec] ..
[rtfspec]  2 Tests ( 2 Successful 0 Failed 0 Pending 0 Exceptions )

I consider the tool far from done but it is already useful. The most important thing missing for me is a matcher structure that will not require you to repeat (= a b) over and over. Also that would be useful to actually print something like “Expected [a] got [b]” as decent testing tools do.

Other thing that I really miss is a way to test a function against a domain represented by a set. During development I realised that just porting a tool like RSpec to Clojure isn’t enough, the needs are different when you use different paradigms.

In both cases the implementation isn’t hard but I can’t think of a nice syntax.

Feedback and patches are always welcome.

2 Responses to “RTFSpec is now in Alpha”


  1. 1 Rob Hunter Apr 18th, 2009 at 7:28 pm

    I think that link is meant to point to “http://www.github.com/pcalcado/rtfspec/tree/” instead of “http://fragmental.tw/2009/04/17/rtfspec-is-now-in-alpha/hub.com/pcalcado/rtfspec/tree/” ;-)

  2. 2 Fabio Lessa Apr 18th, 2009 at 10:38 pm

    nice work man!!
    looks much nicer than the previous implementation.
    i’m coming back to the beach and am gonna fork this thing! ;)

Leave a Reply








Creative Commons License

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.