Tuesday, December 25, 2007

test/spec should.include




test/spec has it's own "assert_include" which is part of ZenTest. In
the default Test::Unit, you check if an array "a" contains an element
"@truffles" with:


assert_send [a, :include?, @truffles]


This is a bit nicer in zentest:


assert_includes @truffles, a


And is very pretty indeed with test/spec:



a.should.include @truffles