Added a method in the rspec file to make the code more DRY