Best practices
9 tips to improve RSpec maintainability
Use the right tool at the right place for the right purpose
Published in
3 min readJun 23, 2020
Writing good test cases is as important as writing good code. Well written specs would help identify bugs as well as act as good documentation.
Here are 9 tips to UP your RSpec game.
There are 2 principles that will lead us through these tips
- DRY — Don’t Repeat Yourself principle
- Use the right tool at the right place for the right purpose
LET’S START!!!
1. Structure the code into the right place
There are three fundamental blocks of every test cases
- Setup —
before
,let
,let!
- Assert —
it
- Teardown —
after
The code should be structured accordingly into the right blocks.