Codebase that contains duplicated code is never easy maintainable.
Krzysztof Maicher
571

As the duplicated code (in this scenario) lives usually within the same spec file, the only challenge in maintenance is editor skills — in most cases find & replace is sufficient. Yet I cannot agree more that actual codebase with lots of duplication cannot be easily maintainable — however there are sometimes cases where duplication can be better choice than over-optimization.

Anyway, in part 2 of this article I will try to list some of techniques used to reduce duplication without sacrificing readability.

P.S. I can see that you are more into super-DRY specs (http://maicher.github.io/how-to-keep-rspecs-dry.html) — that is why I named this guide as “opinionated”. It is by all means a different approach than usual, and duplication is the primary cost here. Still, after writing thousands of tests both ways I find it much more pleasurable to work with. I recommend checking out post by thoughtbot that also provides some related justification https://robots.thoughtbot.com/lets-not

Like what you read? Give Błażej Kosmowski a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.