Recently, after heavy refactoring in a project I had to spent good amount of time in writing specs. After writing almost similar test cases for some APIs, I thought of finding some solution to get rid of duplication in test cases. After reading articles on best practices and drying up tests, I came to know about shared examples and shared contexts. In my case, I ended up using shared examples and here is what I learned so far.
When you have multiple specs that describes similar behavior, it might be better to extract redundant examples in
shared examples and use them in multiple specs.