using StringIO for stubbing as String#each is deprecated.