I would appreciate your input on the following problem: We use Spec to 1) Document what data flows through our code (annotating key transformation functions with it, not just the input and output ones), 2) Auto-generate tests, 3) Verify that the input, coming from an external REST service, is something we can handle. Now the problem is that the raw input is “dirty” and contains data that we want to remove/clean before sending them into the rest of the system (keys with
nil values, users with missing IDs, …).
So it would seem that I need two specs: one more permissive that can accept the real data the service is throwing at us (use case #3) and a stricter one for cleaner, simpler data inside our app (use cases #1, #2). Using the permissive spec everywhere is suboptimal because I will then need to handle the bad data at multiple places (because they will be produced by our generative Spec tests).
How do you people deal with this? Thank you!