On Tue, Feb 23, 2010 at 5:04 PM, Yotta Meter <spam / joeandjody.com> wrote:

>
> Another question, is my philosophy off? I'm a little confused by the
> amount of test options out there, rspec, cucumber, etc. Is there another
> testing strategy I should be working with in this instance where I want
> to iterate through an array of complex objects?
>
> Thanks for not telling me to rtfm or google it.
>
>
If you want to metaprogram tests, you should really look into using dust.
Its only a thin
wrapper around Test::Unit so id doesn't bring with it a steep learning
curve. The main
innovation is that your tests are not distinct methods themselves - you call
the test
method with a string argument (your test name) and you pass in a block which
is your
test code. Behind the scenes it constructs a complete test_foo method for
you.

The main upside to this is that it is super simple to iterate arrays of
arguments and
build up large suites of test methods while you still adhere to the
principle of 'One assert
per test' - which is where you are having issues.

Links:
Dust:
http://blog.jayfields.com/2007/08/rubygems-dust.html

I blogged about using Dust before, the examples aren't completely relevant,
but they do
show you how you can build up tests from arrays:
http://richardconroy.blogspot.com/2008/11/testing-java-code-with-ruby-and-jtestr.html

Understand that RSpec, Cucumber, Coulda, Shoulda, Bacon etc. are solving
different
problems in testing. There is a certain learning curve and conceptual
hurdles to overcome.

Your problem is that you can't coerce Test::Unit to do exactly what you want
it to, but
Test::Unit is perfectly capable of doing it - Dust helps an awful lot
though. I have
done metaprogammed tests in both Test::Unit and Dust, and there is no
comparison.

regards,
Richard.
-- 
http://richardconroy.blogspot.com