← Back to Upcase

Specs - Utilities.rb and Modules


(David Lee) #1

Could someone shed some light on what the difference (if any) is between sticking spec helper functions in a utilities.rb versus creating a module?

For example, in the first Test Driven Rails video, the helper methods (sign_in and sign_in_as) are put in a SignInHelpers module.

If I had to guess, I’d say that the modules may allow for cleaner organization as the code base grows.


(Ben Orenstein) #2

Yep, it’s just an organization strategy.

If you only ever write 3 helper methods, you don’t need to put them in a module. But since you almost always end up writing a decent bunch of them, it can be good to start namespacing them early on.