Writing Non-Brittle Tests Using RSpec’s match Matcher

Photo by Shane Aldendorff on Unsplash

TLDR: RSpec offers a powerful match matcher that will allow you to leverage regular expressions to make non-brittle tests. Coding non-brittle tests that are robust and test behavior instead of implementation will save you maintenance time and lead to overall better quality code.

Figure 1. A simple match assertion
Figure 2. Adding case insensitive flag to regular expression
Figure 3. Checking successful item cart add
Figure 4. Checking that message of unavailable AND the requested shoe size is returned

Former Big Beer Engineer turned Full Stack Software Engineer