I’ve got a single unit test working on a two-variable Portfolio
model. The model has transformations, pattern-matching etc. to clean
up user sloppiness and ensure data quality.
To make sure the transformations/tests remain valid as the model
undergoes future changes, I’ve got about a dozen tests codified in 3-
element hashes: user-input, transformed-value-expected, error-
messages (if any, expected to be produced by the validations)
What’s a better way to handling these triplets?
- write a Ruby script to generate test_1, test_2, etc.
- iterate through list, generate the test_x’s and add those methods
to the PortfoloTest class with metaprogramming.
(I know I could do it manually, but I don’t like to write repetitive
I’ve got the simple working model and test code posted at
http://www.pastie.org/231118. The test code included the hashes
described above included as data in the unit-test file.
Thanks in advance for any suggestions you may offer.