this is my second attempt at "test-first" design, and it's making me beat my head against the wall BEFORE i have much code written, so i guess that's a good thing™
Being a bit of a TDD bigot I'd be interested in understanding what forces are encouraging you to write tests like this. About the only time I write tests that look at, for want of a better term, the generic "shape" of a data structure are when I'm debugging somebody else's code.
When I'm writing fresh code looking at the generic "shape" doesn't really help me write the next bit of code. Looking at progressively more complex concrete instances of the returned data does.
From what you've written so far I don't really understand exactly what foundation_list() does, but would a progression of tests that look something like this make sense to you?
is_deeply( $empty->foundation_list, [], 'empty foundation list' );
is_deeply( $one_option->foundation_list, [ { a => 'b' } ],
'single option foundation list' );
is_deeply( $two_options->foundation_list, [], [ { a => 'b', c => 'd'}
+],
'two option foundation list' );
The idea being that each test would encourage me to write a little bit of code that makes that particular test pass. Develop by increments and refactor all of the time, rather than do everything in large chunks.
Make vague sense? |