This should definitely be pulled out into a class and spec of its own. You're welcome to keep it in the same module but no reason to have a single file.